← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Guruprasad has proposed merging ~lgp171188/launchpad:merge-db-stable into launchpad:master.

Commit message:
Merge 'db-stable' 7ab4bd7a744a92db22cf372769485eb5930c7a44
    
Add 'lock_status' and 'lock_reason' fields to Bug

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~lgp171188/launchpad/+git/launchpad/+merge/414414
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/launchpad:merge-db-stable into launchpad:master.
diff --git a/database/schema/patch-2210-38-0.sql b/database/schema/patch-2210-38-0.sql
new file mode 100644
index 0000000..eef88ec
--- /dev/null
+++ b/database/schema/patch-2210-38-0.sql
@@ -0,0 +1,24 @@
+-- Copyright 2022 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 Bug
+    ADD COLUMN lock_status integer,
+    ADD COLUMN lock_reason text;
+
+-- ALTER COLUMN ... SET DEFAULT doesn't trigger a table rewrite,
+-- while ADD COLUMN ... DEFAULT xx does. In pg <11 this operation is slow.
+-- That's why we first create, and then we set the default value.
+-- Data backfilling will be done in a garbo job instead of a fast downtime.
+
+ALTER TABLE Bug
+    ALTER COLUMN lock_status
+    -- 0 = UNLOCKED
+    SET DEFAULT 0;
+
+COMMENT ON COLUMN Bug.lock_status IS 'The current lock status of this bug.';
+
+COMMENT ON COLUMN Bug.lock_reason IS 'The reason for locking this bug.';
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 38, 0);