Browse files

Added a more complete upgrade SQL script.

  • Loading branch information...
1 parent edcb9cb commit e2114e946a2d52478003faf7955a7620e03ab8ca @jacobian jacobian committed Oct 11, 2010
Showing with 36 additions and 2 deletions.
  1. +36 −2 django_website/upgrade/add_community.sql
38 django_website/upgrade/add_community.sql
@@ -1,2 +1,36 @@
-ALTER TABLE aggregator_feedtype
-ADD COLUMN can_self_add boolean not null default 'true';
+-- Upgrade the DB from the version running on the old
+-- djangoproject server to this new community version.
+-- If we don't do this then we can't do the final SET NOT NULL
+-- step below in the same transaction.
+-- Create the feed type table.
+-- Same as running syncdb, but a little more visible.
+CREATE TABLE "aggregator_feedtype" (
+ "id" serial NOT NULL PRIMARY KEY,
+ "name" varchar(250) NOT NULL,
+ "slug" varchar(250) NOT NULL,
+ "can_self_add" boolean NOT NULL
+-- Create the "blog post" feed type for the old entries in the DB.
+-- This'll get smooshed by the fixture (community_seed.json),
+-- but we need it here to move old data over cleanly.
+INSERT INTO aggregator_feedtype (id, name, slug, can_self_add)
+ VALUES (2, 'Community Blog Posts', 'community-blog-posts', 't');
+-- Add the feed_type_id column to aggregator_feeds and update it
+-- to point to the new feed type.
+ALTER TABLE aggregator_feeds ADD COLUMN feed_type_id integer
+UPDATE aggregator_feeds SET feed_type_id = 2;
+ALTER TABLE aggregator_feeds ALTER COLUMN feed_type_id SET NOT NULL;

0 comments on commit e2114e9

Please sign in to comment.