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

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 0975e9fe364e2270a15b2aeaac0a1dcdf4144a38
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:ocirecipe-git-path-allow-null
Merge into: launchpad:db-devel
Diff against target: 14 lines (+8/-0)
1 file modified
database/schema/patch-2210-08-4.sql (+8/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) db Approve
Review via email: mp+380038@code.launchpad.net

Commit message

Allow OCIRecipe.git_path to be null and add constraints

Description of the change

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*

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
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-2210-08-4.sql b/database/schema/patch-2210-08-4.sql
2new file mode 100644
3index 0000000..4656bb7
4--- /dev/null
5+++ b/database/schema/patch-2210-08-4.sql
6@@ -0,0 +1,8 @@
7+-- Copyright 2020 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+ALTER TABLE OCIRecipe ALTER COLUMN git_path DROP NOT NULL;
11+
12+ALTER TABLE OCIRecipe ADD CONSTRAINT consistent_git_ref CHECK ((git_repository IS NULL) = (git_path IS NULL));
13+
14+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 08, 4);

Subscribers

People subscribed via source and target branches

to status/vote changes: