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

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 95d647b3a4478bd91309385b3ed23d48dc2bf2ba
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:webhook-patterns/add-db-patch
Merge into: launchpad:db-devel
Diff against target: 22 lines (+16/-0)
1 file modified
database/schema/patch-2211-20-0.sql (+16/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Colin Watson (community) db Approve
Review via email: mp+446950@code.launchpad.net

Commit message

Add DB patch for git ref pattern filters for webhooks

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

Description of the change

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`

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) :
Revision history for this message
Colin Watson (cjwatson) wrote :

Adding William for a second DB review.

review: Approve (db)
Revision history for this message
William Grant (wgrant) wrote :

Looks good once Colin's comments are addressed. Thanks!

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2211-20-0.sql b/database/schema/patch-2211-20-0.sql
2new file mode 100644
3index 0000000..cff025a
4--- /dev/null
5+++ b/database/schema/patch-2211-20-0.sql
6@@ -0,0 +1,16 @@
7+-- Copyright 2023 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+ALTER TABLE Webhook ADD COLUMN git_ref_pattern text;
13+ALTER TABLE CIBuild ADD COLUMN git_refs text[];
14+
15+COMMENT ON COLUMN Webhook.git_ref_pattern IS 'Pattern to use to filter git repository webhook triggers by their git refs.';
16+COMMENT ON COLUMN CIBuild.git_refs IS 'Git refs that originated the CI Build.';
17+
18+ALTER TABLE Webhook ADD CONSTRAINT ref_pattern_for_git CHECK (
19+ (git_ref_pattern IS NULL OR git_repository IS NOT NULL)
20+);
21+
22+INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 20, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: