← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:merge-db-stable into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:merge-db-stable into launchpad:master.

Commit message:
Merge db-stable 962c4aa24c8006b0f8d154b4642df4f20e725180 (GitRepository.oci_project and OCIProject.project new columns)

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/385500
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:merge-db-stable into launchpad:master.
diff --git a/database/schema/patch-2210-08-8.sql b/database/schema/patch-2210-08-8.sql
new file mode 100644
index 0000000..5a20873
--- /dev/null
+++ b/database/schema/patch-2210-08-8.sql
@@ -0,0 +1,48 @@
+-- Copyright 2020 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+ALTER TABLE OCIProject ADD COLUMN project integer REFERENCES product;
+
+ALTER TABLE OCIProject
+    ALTER COLUMN distribution
+    DROP NOT NULL,
+    ADD CONSTRAINT one_container
+        CHECK ((project IS NULL) != (distribution IS NULL));
+
+COMMENT ON COLUMN OCIProject.project
+    IS 'The project that this OCI project is associated with.';
+
+CREATE UNIQUE INDEX ociproject__project__ociprojectname__key
+    ON OCIProject (project, ociprojectname) WHERE project IS NOT NULL;
+
+
+-- Alter GitRepository table to allow oci_project.
+COMMENT ON COLUMN GitRepository.ociprojectname
+    IS 'Deprecated column. Check one_container and default_implies_target constraints before removing.';
+
+ALTER TABLE GitRepository
+    ADD COLUMN oci_project integer REFERENCES ociproject,
+    DROP CONSTRAINT one_container,
+    ADD CONSTRAINT one_container CHECK (
+        -- Distribution + OCIProjectName, to keep compatibility temporarily
+        (project IS NULL AND distribution IS NOT NULL AND sourcepackagename IS NULL AND ociprojectname IS NOT NULL) OR
+        -- Project
+        (project IS NOT NULL AND distribution IS NULL AND sourcepackagename IS NULL AND oci_project IS NULL AND ociprojectname IS NULL) OR
+        -- Distribution source package
+        (project IS NULL AND distribution IS NOT NULL AND sourcepackagename IS NOT NULL AND oci_project IS NULL AND ociprojectname IS NULL) OR
+        -- OCI project
+        (project IS NULL AND distribution IS NULL AND sourcepackagename IS NULL AND oci_project IS NOT NULL AND ociprojectname IS NULL) OR
+        -- Personal
+        (project IS NULL AND distribution IS NULL AND sourcepackagename IS NULL AND oci_project IS NULL))
+        NOT VALID,
+    DROP CONSTRAINT default_implies_target,
+    ADD CONSTRAINT default_implies_target CHECK (
+        project IS NOT NULL
+        OR distribution IS NOT NULL
+        OR oci_project IS NOT NULL
+        OR (NOT owner_default AND NOT target_default))
+        NOT VALID;
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 8, 8);
diff --git a/database/schema/patch-2210-16-0.sql b/database/schema/patch-2210-16-0.sql
new file mode 100644
index 0000000..2debdba
--- /dev/null
+++ b/database/schema/patch-2210-16-0.sql
@@ -0,0 +1,15 @@
+-- Copyright 2020 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+ALTER TABLE OCIFile
+ADD COLUMN date_last_used timestamp without time zone
+    DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL;
+
+COMMENT ON COLUMN OCIFile.date_last_used IS 'The datetime this file was last used in a build.';
+
+CREATE INDEX ocifile__date_last_used__idx
+    ON OCIFile (date_last_used);
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 16, 0);

Follow ups