launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24434
[Merge] ~twom/launchpad:oci-recipe-git-repository-constraint into launchpad:db-devel
Tom Wardill has proposed merging ~twom/launchpad:oci-recipe-git-repository-constraint into launchpad:db-devel.
Commit message:
Add constraint to OCIRecipe.git_repository and git_path
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/380200
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-recipe-git-repository-constraint into launchpad:db-devel.
diff --git a/database/schema/patch-2210-08-5.sql b/database/schema/patch-2210-08-5.sql
new file mode 100644
index 0000000..7d5cef4
--- /dev/null
+++ b/database/schema/patch-2210-08-5.sql
@@ -0,0 +1,6 @@
+-- Copyright 2020 Canonical Ltd. This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+ALTER TABLE OCIRecipe ADD CONSTRAINT consistent_git_ref CHECK ((git_repository IS NULL) = (git_path IS NULL));
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 08, 5);
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index 2bf8068..99593a3 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -152,8 +152,8 @@ class OCIRecipe(Storm):
def git_ref(self, value):
"""See `IOCIRecipe`."""
if value is not None:
- self.git_path = value.path
self.git_repository = value.repository
+ self.git_path = value.path
else:
self.git_repository = None
self.git_path = None