← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:cold-db-patch-ociproject-project-pillar into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:cold-db-patch-ociproject-project-pillar into launchpad:master.

Commit message:
Changing GitRepository indexes to support projects as pillars of OCI projects.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/383897

This cold patch should be applied manually, with CONCURRENTLY on the indexes creation.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:cold-db-patch-ociproject-project-pillar into launchpad:master.
diff --git a/database/schema/patch-2210-08-9.sql b/database/schema/patch-2210-08-9.sql
new file mode 100644
index 0000000..c199c18
--- /dev/null
+++ b/database/schema/patch-2210-08-9.sql
@@ -0,0 +1,37 @@
+-- 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;
+
+-- Create new UNIQUE constraints to replace existing distribution + ociprojectname ones.
+CREATE UNIQUE INDEX gitrepository__owner__oci_project__name__key
+    ON GitRepository (owner, oci_project, name)
+    WHERE oci_project IS NOT NULL;
+
+CREATE UNIQUE INDEX gitrepository__owner__oci_project__owner_default__key
+    ON GitRepository (owner, oci_project)
+    WHERE oci_project IS NOT NULL AND owner_default;
+
+CREATE UNIQUE INDEX gitrepository__oci_project__target_default__key
+    ON GitRepository (oci_project)
+    WHERE oci_project IS NOT NULL AND target_default;
+
+
+-- Create new indexes to replace existing ociprojectname ones
+CREATE INDEX "gitrepository__oci_project__date_last_modified__idx"
+    ON GitRepository (oci_project, date_last_modified)
+    WHERE oci_project IS NOT NULL;
+
+CREATE INDEX "gitrepository__oci_project__id__idx"
+    ON GitRepository (oci_project, id);
+
+CREATE INDEX "gitrepository__owner__oci_project__date_last_modified__idx"
+    ON GitRepository (owner, oci_project, date_last_modified)
+    WHERE oci_project IS NOT NULL;
+
+CREATE INDEX "gitrepository__owner__oci_project__id__idx"
+    ON GitRepository (owner, oci_project, id)
+    WHERE oci_project IS NOT NULL;
+
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 8, 9);