← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cprov/launchpad/snap-privacy-db into lp:launchpad/db-devel

 

Celso Providelo has proposed merging lp:~cprov/launchpad/snap-privacy-db into lp:launchpad/db-devel.

Commit message:
Database changes for improving privacy on Snap-related models.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cprov/launchpad/snap-privacy-db/+merge/282531

Database changes for improving privacy on Snap-related models.

Mode details on https://docs.google.com/document/d/1YtT_8OYtvrQLWQq0kKh-SS7l7f2oWtTrx0w7D3W_Ui4/edit

I wasn't sure if we can / should be doing data migration (snap.[branch, git] to snapbuild) as part of this patch initial DB patch or if there is something more effective (less blocking, I mean) for this.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cprov/launchpad/snap-privacy-db into lp:launchpad/db-devel.
=== added file 'database/schema/patch-2209-73-0.sql'
--- database/schema/patch-2209-73-0.sql	1970-01-01 00:00:00 +0000
+++ database/schema/patch-2209-73-0.sql	2016-01-14 01:24:38 +0000
@@ -0,0 +1,30 @@
+-- Copyright 2015 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+-- Snap privacy model is based only on ownership, similarly to Archives.
+ALTER TABLE Snap ADD COLUMN private boolean DEFAULT false NOT NULL;
+
+COMMENT ON COLUMN Snap.private IS 'Whether or not this snap is only visible to owners.';
+
+CREATE INDEX snap__private__idx ON snap USING btree (private);
+
+
+-- Copying original snap branch references to SnapBuild on creation, this way
+-- we can accurately calculate permission on builds after snap changes. 
+ALTER TABLE SnapBuild ADD COLUMN branch integer REFERENCES Branch;
+ALTER TABLE SnapBuild ADD COLUMN git_repository integer REFERENCES GitRepository;
+ALTER TABLE SnapBuild ADD COLUMN git_path text;
+ALTER TABLE SnapBuild ADD CONSTRAINT consistent_git_ref
+    CHECK ((git_repository IS NULL) = (git_path IS NULL));
+
+COMMENT ON COLUMN SnapBuild.branch IS 'Copied from Snap.branch on creation.';
+COMMENT ON COLUMN SnapBuild.git_repository IS 'Copied from Snap.git_repository on creation.';
+COMMENT ON COLUMN SnapBuild.git_path IS 'Copied from Snap.git_path on creation.';
+
+CREATE INDEX snapbuild__branch__idx ON SnapBuild (branch);
+CREATE INDEX snapbuild__git_repository__idx ON SnapBuild (git_repository);
+
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 73, 0);