summaryrefslogtreecommitdiffstats
path: root/lib/sql/migration
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2011-09-19 09:42:44 +0800
committerJeremy Kerr <jk@ozlabs.org>2011-09-19 09:42:44 +0800
commit75d8cf966034e673afe0077ba393d8b2eb3e9b93 (patch)
tree3f6cf6b9f87ad313d23de77b4c33422e7444a1df /lib/sql/migration
parent539b6596dc1bf1d3118631095625e354026da373 (diff)
parentf1e5f6a2c9d737f12290f5bd5a934b74c362616f (diff)
downloadpatchwork-75d8cf966034e673afe0077ba393d8b2eb3e9b93.tar.bz2
patchwork-75d8cf966034e673afe0077ba393d8b2eb3e9b93.tar.xz
Merge branch 'notifications'
Diffstat (limited to 'lib/sql/migration')
-rw-r--r--lib/sql/migration/008-confirmations.sql11
-rw-r--r--lib/sql/migration/009-drop-registrationprofile.sql27
-rw-r--r--lib/sql/migration/010-optout-tables.sql5
-rw-r--r--lib/sql/migration/011-patch-change-notifications.sql12
4 files changed, 55 insertions, 0 deletions
diff --git a/lib/sql/migration/008-confirmations.sql b/lib/sql/migration/008-confirmations.sql
new file mode 100644
index 0000000..89437a2
--- /dev/null
+++ b/lib/sql/migration/008-confirmations.sql
@@ -0,0 +1,11 @@
+BEGIN;
+ALTER TABLE "patchwork_userpersonconfirmation"
+ RENAME TO "patchwork_emailconfirmation";
+ALTER SEQUENCE "patchwork_userpersonconfirmation_id_seq"
+ RENAME TO "patchwork_emailconfirmation_id_seq";
+ALTER TABLE "patchwork_emailconfirmation"
+ ALTER COLUMN "user_id" DROP NOT NULL,
+ ADD COLUMN "type" varchar(20) NOT NULL DEFAULT 'userperson';
+ALTER TABLE "patchwork_emailconfirmation"
+ ALTER COLUMN "type" DROP DEFAULT;
+COMMIT;
diff --git a/lib/sql/migration/009-drop-registrationprofile.sql b/lib/sql/migration/009-drop-registrationprofile.sql
new file mode 100644
index 0000000..f1c2b43
--- /dev/null
+++ b/lib/sql/migration/009-drop-registrationprofile.sql
@@ -0,0 +1,27 @@
+BEGIN;
+
+DELETE FROM registration_registrationprofile;
+
+-- unlink users who have contributed
+
+UPDATE patchwork_person SET user_id = NULL
+ WHERE user_id IN (SELECT id FROM auth_user WHERE is_active = False)
+ AND id IN (SELECT DISTINCT submitter_id FROM patchwork_comment);
+
+-- remove persons who only have a user linkage
+
+DELETE FROM patchwork_person WHERE user_id IN
+ (SELECT id FROM auth_user WHERE is_active = False);
+
+-- delete profiles
+
+DELETE FROM patchwork_userprofile WHERE user_id IN
+ (SELECT id FROM auth_user WHERE is_active = False);
+
+-- delete inactive users
+
+DELETE FROM auth_user WHERE is_active = False;
+
+DROP TABLE registration_registrationprofile;
+
+COMMIT;
diff --git a/lib/sql/migration/010-optout-tables.sql b/lib/sql/migration/010-optout-tables.sql
new file mode 100644
index 0000000..0a5d835
--- /dev/null
+++ b/lib/sql/migration/010-optout-tables.sql
@@ -0,0 +1,5 @@
+BEGIN;
+CREATE TABLE "patchwork_emailoptout" (
+ "email" varchar(200) NOT NULL PRIMARY KEY
+);
+COMMIT;
diff --git a/lib/sql/migration/011-patch-change-notifications.sql b/lib/sql/migration/011-patch-change-notifications.sql
new file mode 100644
index 0000000..0a9b9b7
--- /dev/null
+++ b/lib/sql/migration/011-patch-change-notifications.sql
@@ -0,0 +1,12 @@
+BEGIN;
+CREATE TABLE "patchwork_patchchangenotification" (
+ "patch_id" integer NOT NULL PRIMARY KEY REFERENCES "patchwork_patch" ("id") DEFERRABLE INITIALLY DEFERRED,
+ "last_modified" timestamp with time zone NOT NULL,
+ "orig_state_id" integer NOT NULL REFERENCES "patchwork_state" ("id") DEFERRABLE INITIALLY DEFERRED
+)
+;
+ALTER TABLE "patchwork_project" ADD COLUMN
+ "send_notifications" boolean NOT NULL DEFAULT False;
+ALTER TABLE "patchwork_project" ALTER COLUMN
+ "send_notifications" DROP DEFAULT;
+COMMIT;