← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stub/launchpad/pending-db-changes into lp:launchpad/db-devel

 

Stuart Bishop has proposed merging lp:~stub/launchpad/pending-db-changes into lp:launchpad/db-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #844616 in Launchpad itself: "full-update.py too picky about long running transactions"
  https://bugs.launchpad.net/launchpad/+bug/844616

For more details, see:
https://code.launchpad.net/~stub/launchpad/pending-db-changes/+merge/83005

Space to store Bazaar branch details of the code used to perform database updates.
-- 
https://code.launchpad.net/~stub/launchpad/pending-db-changes/+merge/83005
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/pending-db-changes into lp:launchpad/db-devel.
=== modified file 'database/replication/helpers.py'
--- database/replication/helpers.py	2011-10-13 03:52:48 +0000
+++ database/replication/helpers.py	2011-11-22 11:55:11 +0000
@@ -44,7 +44,6 @@
     ('public', 'openidnonce'),
     ('public', 'openidassociation'),
     ('public', 'person'),
-    ('public', 'launchpaddatabaserevision'),
     ('public', 'databasereplicationlag'),
     ('public', 'fticache'),
     ('public', 'nameblacklist'),
@@ -63,6 +62,16 @@
     # suggestivepotemplate.potemplate foreign key constraint exists on
     # production.
     ('public', 'suggestivepotemplate'),
+    # These are odd. They are updated via slonik & EXECUTE SCRIPT, and
+    # the contents of these tables will be different on each node
+    # because we store timestamps when the patches were applied.
+    # However, we want the tables listed as replicated so that, when
+    # building a new replica, the data that documents the schema patch
+    # level matches the schema patch level and upgrade.py does the right
+    # thing. This is a bad thing to do, but we are safe in this
+    # particular case.
+    ('public', 'launchpaddatabaserevision'),
+    ('public', 'launchpaddatabaseupdatelog'),
     ])
 
 # Explicitly list tables that should not be replicated. This includes the

=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql	2011-11-16 01:19:54 +0000
+++ database/schema/comments.sql	2011-11-22 11:55:11 +0000
@@ -1223,6 +1223,9 @@
 COMMENT ON COLUMN LaunchpadDatabaseRevision.minor IS 'Minor number. Patches made during development each increment the minor number.';
 COMMENT ON COLUMN LaunchpadDatabaseRevision.patch IS 'The patch number will hopefully always be ''0'', as it exists to support emergency patches made to the production server. eg. If production is running ''4.0.0'' and needs to have a patch applied ASAP, we would create a ''4.0.1'' patch and roll it out. We then may need to refactor all the existing ''4.x.0'' patches.';
 
+-- LaunchpadDatabaseUpdateLog
+COMMENT ON TABLE LaunchpadDatabaseUpdateLog IS 'Record of Launchpad database schema updates. When and what update.py was run.';
+
 -- Karma
 COMMENT ON TABLE Karma IS 'Used to quantify all the ''operations'' a user performs inside the system, which maybe reporting and fixing bugs, uploading packages, end-user support, wiki editting, etc.';
 COMMENT ON COLUMN Karma.action IS 'A foreign key to the KarmaAction table.';

=== added file 'database/schema/patch-2208-01-3.sql'
--- database/schema/patch-2208-01-3.sql	1970-01-01 00:00:00 +0000
+++ database/schema/patch-2208-01-3.sql	2011-11-22 11:55:11 +0000
@@ -0,0 +1,17 @@
+SET client_min_messages=ERROR;
+
+ALTER TABLE LaunchpadDatabaseRevision
+    ADD branch_nick text,
+    ADD revno integer,
+    ADD revid text;
+
+CREATE TABLE LaunchpadDatabaseUpdateLog (
+    id serial primary key,
+    start_time timestamp without time zone NOT NULL DEFAULT (
+        CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
+    end_time timestamp without time zone,
+    branch_nick text,
+    revno integer,
+    revid text);
+   
+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 01, 3);