Merge ~pappacena/launchpad:hot-gitrepo-status-column into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: 07033badf87f7b436779d2d2dda9c131e4209e6f
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:hot-gitrepo-status-column
Merge into: launchpad:master
Diff against target: 23 lines (+17/-0)
1 file modified
database/schema/patch-2210-17-1.sql (+17/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) db Approve
Review via email: mp+385198@code.launchpad.net

Commit message

Hot patch to add index, default value and NOT NULL constraint to GitRepository.status.

Description of the change

This database patch should be applied "hot", with CONCURRENTLY on the index creation, after the MP https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/385199 is landed.

To post a comment you must log in.
a1de430... by Thiago F. Pappacena

Setting default value for GitRepo.status and moving index creation to the end

Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Colin Watson (cjwatson) :
review: Approve (db)
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

cjwatson, added a comment about the index creation.

Revision history for this message
Colin Watson (cjwatson) :
07033ba... by Thiago F. Pappacena

Changing index creation for gitrepository.date_created / status

Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Pushed the changes to turn GitRepository.status index into GitRepository.date_created index, filtered by status = 1 (creating).

Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Merging it to master now that it was run in production.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2210-17-1.sql b/database/schema/patch-2210-17-1.sql
2new file mode 100644
3index 0000000..f1813af
4--- /dev/null
5+++ b/database/schema/patch-2210-17-1.sql
6@@ -0,0 +1,17 @@
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+-- Status "2" is GitRepositoryStatus.AVAILABLE
13+UPDATE GitRepository SET status = 2 WHERE status IS NULL;
14+
15+ALTER TABLE GitRepository
16+ ALTER COLUMN status SET NOT NULL;
17+
18+CREATE INDEX gitrepository__date_created__status__idx
19+ ON GitRepository (date_created)
20+ -- 1 == CREATING
21+ WHERE status = 1;
22+
23+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 17, 1);