← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ines-almeida/launchpad:webhook-patterns/add-db-patch into launchpad:db-devel

 

Ines Almeida has proposed merging ~ines-almeida/launchpad:webhook-patterns/add-db-patch into launchpad:db-devel.

Commit message:
Add DB patch for git ref pattern filters for webhooks

Add 'git_refs' column to CIBuilds and 'ref_pattern' to Webhooks table

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/446950

Two columns added here:
 - The `ref_pattern` will be used by webhooks targeted at git repositories for filtering webhook triggers according to their corresponding git_refs. Webhooks with other targets shouldn't have this field.
 - The `git_refs` will be a new read-only field of CI Builds that will store which git_refs originated a build, which will in turn be used to filter webhook triggers according to `ref_pattern`
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:webhook-patterns/add-db-patch into launchpad:db-devel.
diff --git a/database/schema/patch-2211-20-0.sql b/database/schema/patch-2211-20-0.sql
new file mode 100644
index 0000000..db0e9fc
--- /dev/null
+++ b/database/schema/patch-2211-20-0.sql
@@ -0,0 +1,22 @@
+-- Copyright 2023 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+-- Webhook
+
+ALTER TABLE Webhook ADD COLUMN ref_pattern text;
+
+COMMENT ON COLUMN Webhook.ref_pattern IS 'Pattern to use to filter git repository webhook triggers by their git refs.';
+
+ALTER TABLE Webhook ADD CONSTRAINT ref_pattern_for_git CHECK (
+    (ref_pattern IS NULL OR git_repository IS NOT NULL)
+);
+
+-- CI Build
+
+ALTER TABLE CIBuild ADD COLUMN git_refs text[];
+
+COMMENT ON COLUMN CIBuild.git_refs IS 'Git refs that originated the CI Build.';
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 20, 0);