Merge lp:~cjwatson/launchpad/db-git-recipes into lp:launchpad/db-devel

Proposed by Colin Watson on 2016-01-07
Status: Merged
Merged at revision: 13319
Proposed branch: lp:~cjwatson/launchpad/db-git-recipes
Merge into: lp:launchpad/db-devel
Diff against target: 34 lines (+30/-0)
1 file modified
database/schema/patch-2209-73-0.sql (+30/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/db-git-recipes
Reviewer Review Type Date Requested Status
William Grant db 2016-01-07 Approve on 2016-01-14
Stuart Bishop db 2016-01-07 Pending
Review via email: mp+281887@code.launchpad.net

Commit message

Add SourcePackageRecipeData.base_git_repository and SourcePackageRecipeDataInstruction.git_repository columns.

Description of the change

Add SourcePackageRecipeData.base_git_repository and SourcePackageRecipeDataInstruction.git_repository columns.

I believe that this is enough to support Git recipes. We don't need reference paths in this case, because recipes already have a "revspec" which in the Git case may name a reference (or a specific commit, or ...). This simplifies things.

I considered adding a constraint to the effect that if SourcePackageRecipeData.base_branch is not null then all the SourcePackageRecipeDataInstruction rows that refer to it must use branch rather than git_repository and vice versa, but I think that ends up being overcomplicated and doesn't buy us very much. Let me know if you disagree.

To post a comment you must log in.
William Grant (wgrant) wrote :

You also need indexes on the new columns, and probably some kind of deletion handling.

review: Needs Fixing
Colin Watson (cjwatson) wrote :

I've sorted out the indexes (and checked that the DROP/CREATE on the index for base_branch is quick on dogfood - sub-100ms to create the modified index). As per IRC, deletion handling isn't needed in the database branch because it'll be handled explicitly in GitRepository._getDeletionRequirements.

William Grant (wgrant) :
review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2209-73-0.sql'
2--- database/schema/patch-2209-73-0.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2209-73-0.sql 2016-01-11 14:38:00 +0000
4@@ -0,0 +1,30 @@
5+-- Copyright 2016 Canonical Ltd. This software is licensed under the
6+-- GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+SET client_min_messages=ERROR;
9+
10+ALTER TABLE SourcePackageRecipeData
11+ ADD COLUMN base_git_repository integer REFERENCES GitRepository;
12+ALTER TABLE SourcePackageRecipeData
13+ ALTER COLUMN base_branch DROP NOT NULL;
14+ALTER TABLE SourcePackageRecipeData
15+ ADD CONSTRAINT one_base_vcs CHECK ((base_branch IS NOT NULL) != (base_git_repository IS NOT NULL));
16+
17+DROP INDEX sourcepackagerecipedata__base_branch__idx;
18+CREATE INDEX sourcepackagerecipedata__base_branch__idx
19+ ON SourcePackageRecipeData(base_branch) WHERE base_branch IS NOT NULL;
20+CREATE INDEX sourcepackagerecipedata__base_git_repository__idx
21+ ON SourcePackageRecipeData(base_git_repository) WHERE base_git_repository IS NOT NULL;
22+
23+COMMENT ON COLUMN SourcePackageRecipeData.base_git_repository IS 'The Git repository the recipe is based on.';
24+
25+ALTER TABLE SourcePackageRecipeDataInstruction
26+ ADD COLUMN git_repository integer REFERENCES GitRepository;
27+ALTER TABLE SourcePackageRecipeDataInstruction
28+ ALTER COLUMN branch DROP NOT NULL;
29+ALTER TABLE SourcePackageRecipeDataInstruction
30+ ADD CONSTRAINT one_vcs CHECK ((branch IS NOT NULL) != (git_repository IS NOT NULL));
31+
32+COMMENT ON COLUMN SourcePackageRecipeDataInstruction.git_repository IS 'The Git repository containing the branch being merged or nested.';
33+
34+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 73, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: