← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:db-oci-webhooks into launchpad:db-devel

 

Colin Watson has proposed merging ~cjwatson/launchpad:db-oci-webhooks into launchpad:db-devel.

Commit message:
Add Webhook.oci_recipe column

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/380350
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:db-oci-webhooks into launchpad:db-devel.
diff --git a/database/schema/patch-2210-10-1.sql b/database/schema/patch-2210-10-1.sql
new file mode 100644
index 0000000..9206f6a
--- /dev/null
+++ b/database/schema/patch-2210-10-1.sql
@@ -0,0 +1,14 @@
+-- Copyright 2019 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+ALTER TABLE Webhook ADD COLUMN oci_recipe integer REFERENCES OCIRecipe;
+
+ALTER TABLE Webhook DROP CONSTRAINT one_target;
+ALTER TABLE Webhook ADD CONSTRAINT one_target CHECK (null_count(ARRAY[git_repository, branch, snap, livefs, oci_recipe]) = 4);
+
+CREATE INDEX webhook__oci_recipe__id__idx
+    ON webhook(oci_recipe, id) WHERE oci_recipe IS NOT NULL;
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 10, 1);