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

Proposed by Thiago F. Pappacena
Status: Superseded
Proposed branch: ~pappacena/launchpad:cold-db-patch-ociproject-project-pillar
Merge into: launchpad:master
Diff against target: 44 lines (+38/-0)
1 file modified
database/schema/patch-2210-08-9.sql (+38/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+383897@code.launchpad.net

This proposal has been superseded by a proposal from 2020-05-27.

Commit message

Changing GitRepository indexes to support projects as pillars of OCI projects.

Description of the change

This hot patch should be applied manually, with CONCURRENTLY on the indexes creation.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

In our terminology, this is a hot patch, not a cold patch (2210-08-8 is a cold patch). It would be a good idea to rename the branch and adjust the MP description to avoid possible confusion.

review: Approve
e50b04e... by Thiago F. Pappacena

Fixing missing condition on index creation

Unmerged commits

e50b04e... by Thiago F. Pappacena

Fixing missing condition on index creation

a927d0f... by Thiago F. Pappacena

Index and unique constraints for GitRepository.oci_project

ccaed55... by Thiago F. Pappacena

Fixing syntax error

ea3a8e3... by Thiago F. Pappacena

GitRepository index changes for project as pillar for OCIProject

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-9.sql b/database/schema/patch-2210-08-9.sql
2new file mode 100644
3index 0000000..414b516
4--- /dev/null
5+++ b/database/schema/patch-2210-08-9.sql
6@@ -0,0 +1,38 @@
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+SET client_min_messages=ERROR;
11+
12+-- Create new UNIQUE constraints to replace existing distribution + ociprojectname ones.
13+CREATE UNIQUE INDEX gitrepository__owner__oci_project__name__key
14+ ON GitRepository (owner, oci_project, name)
15+ WHERE oci_project IS NOT NULL;
16+
17+CREATE UNIQUE INDEX gitrepository__owner__oci_project__owner_default__key
18+ ON GitRepository (owner, oci_project)
19+ WHERE oci_project IS NOT NULL AND owner_default;
20+
21+CREATE UNIQUE INDEX gitrepository__oci_project__target_default__key
22+ ON GitRepository (oci_project)
23+ WHERE oci_project IS NOT NULL AND target_default;
24+
25+
26+-- Create new indexes to replace existing ociprojectname ones
27+CREATE INDEX "gitrepository__oci_project__date_last_modified__idx"
28+ ON GitRepository (oci_project, date_last_modified)
29+ WHERE oci_project IS NOT NULL;
30+
31+CREATE INDEX "gitrepository__oci_project__id__idx"
32+ ON GitRepository (oci_project, id)
33+ WHERE oci_project IS NOT NULL;
34+
35+CREATE INDEX "gitrepository__owner__oci_project__date_last_modified__idx"
36+ ON GitRepository (owner, oci_project, date_last_modified)
37+ WHERE oci_project IS NOT NULL;
38+
39+CREATE INDEX "gitrepository__owner__oci_project__id__idx"
40+ ON GitRepository (owner, oci_project, id)
41+ WHERE oci_project IS NOT NULL;
42+
43+
44+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 8, 9);