← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:ocirecipe-git-path-allow-null into launchpad:db-devel

 

Tom Wardill has proposed merging ~twom/launchpad:ocirecipe-git-path-allow-null into launchpad:db-devel.

Commit message:
Allow OCIRecipe.git_path to be null and add constraints

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/380038

We want to be able to 'detach' the OCIRecipe from it's repository (for instance, allowing the repo to be deleted, but maintaining the history and configuration of the recipe).
Allow git_path to be NULL, the same as git_repository, and add a constraint that if one is NULL, the other should be too.

Matches the behaviour of Snap*
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:ocirecipe-git-path-allow-null into launchpad:db-devel.
diff --git a/database/schema/patch-2210-08-4.sql b/database/schema/patch-2210-08-4.sql
new file mode 100644
index 0000000..4656bb7
--- /dev/null
+++ b/database/schema/patch-2210-08-4.sql
@@ -0,0 +1,8 @@
+-- Copyright 2020 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+ALTER TABLE OCIRecipe ALTER COLUMN git_path DROP NOT NULL;
+
+ALTER TABLE OCIRecipe ADD CONSTRAINT consistent_git_ref CHECK ((git_repository IS NULL) = (git_path IS NULL));
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 08, 4);