← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/db-fix-bug-779406 into lp:launchpad/db-devel

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/db-fix-bug-779406 into lp:launchpad/db-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/db-fix-bug-779406/+merge/60347

Clean up the database patch that adds parent_series to DSD. We now add the column, migrate existing data for Ubuntu only, and then set NOT NULL on the column.
-- 
https://code.launchpad.net/~stevenk/launchpad/db-fix-bug-779406/+merge/60347
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/db-fix-bug-779406 into lp:launchpad/db-devel.
=== modified file 'database/schema/patch-2208-64-0.sql'
--- database/schema/patch-2208-64-0.sql	2011-05-02 06:42:52 +0000
+++ database/schema/patch-2208-64-0.sql	2011-05-09 09:11:09 +0000
@@ -3,8 +3,12 @@
 SET client_min_messages=ERROR;
 
 ALTER TABLE DistroSeriesDifference
-    ADD COLUMN parent_series INTEGER NOT NULL
+    ADD COLUMN parent_series INTEGER
         CONSTRAINT distroseriesdifference__parentseries__fk REFERENCES distroseries;
+-- Because of the likelyhood of staging and production having existing data,
+-- we need to set it, but only for Ubuntu.
+UPDATE DistroSeriesDifference SET parent_series = (SELECT id from DistroSeries WHERE name = 'sid') FROM Distribution, DistroSeries WHERE Distribution.name = 'ubuntu' AND DistroSeries.id = derived_series AND DistroSeries.distribution = Distribution.id;
+ALTER TABLE DistroSeriesDifference ALTER COLUMN parent_series SET NOT NULL;
 
 CREATE INDEX distroseriesdifference__parent_series__idx ON DistroSeriesDifference(parent_series);