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

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

Commit message

Merge db-stable 9b0e0a8303b913dd6ba56af663e5e3df8c8dcdac (Add GitRepository.status column)

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Deployed to the production database today.

review: Approve

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-0.sql b/database/schema/patch-2210-17-0.sql
2new file mode 100644
3index 0000000..3f5946a
4--- /dev/null
5+++ b/database/schema/patch-2210-17-0.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+ALTER TABLE GitRepository ADD COLUMN status INTEGER;
13+
14+-- ALTER COLUMN ... SET DEFAULT doesn't trigger a table rewrite,
15+-- while ADD COLUMN ... DEFAULT xx does. In pg <11 this operation is slow.
16+-- That's why we first create, and then we set the default value.
17+-- Data backfilling will be done in a hot patch instead of a fast downtime.
18+ALTER TABLE GitRepository ALTER COLUMN status SET DEFAULT 2;
19+
20+COMMENT ON COLUMN GitRepository.status
21+ IS 'The current status of this git repository.';
22+
23+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 17, 0);