Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a more complete upgrade SQL script.

  • Loading branch information...
commit e2114e946a2d52478003faf7955a7620e03ab8ca 1 parent edcb9cb
Jacob Kaplan-Moss jacobian authored
Showing with 36 additions and 2 deletions.
  1. +36 −2 django_website/upgrade/add_community.sql
38 django_website/upgrade/add_community.sql
View
@@ -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.
+
+BEGIN;
+
+-- If we don't do this then we can't do the final SET NOT NULL
+-- step below in the same transaction.
+
+SET CONSTRAINTS ALL IMMEDIATE;
+
+-- 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
+ REFERENCES aggregator_feedtype (id) DEFERRABLE INITIALLY DEFERRED;
+UPDATE aggregator_feeds SET feed_type_id = 2;
+ALTER TABLE aggregator_feeds ALTER COLUMN feed_type_id SET NOT NULL;
+
+COMMIT;
Please sign in to comment.
Something went wrong with that request. Please try again.