]> git.ozlabs.org Git - patchwork/commitdiff
sql: Add uncommitted migration scripts
authorJeremy Kerr <jk@ozlabs.org>
Tue, 10 Aug 2010 03:22:01 +0000 (11:22 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 10 Aug 2010 03:49:36 +0000 (11:49 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/sql/migration/003-add-comment-parent.sql [new file with mode: 0644]
lib/sql/migration/006-maintainer-project-attributes.sql [new file with mode: 0644]

diff --git a/lib/sql/migration/003-add-comment-parent.sql b/lib/sql/migration/003-add-comment-parent.sql
new file mode 100644 (file)
index 0000000..e6f9f64
--- /dev/null
@@ -0,0 +1,7 @@
+BEGIN;
+ALTER TABLE "patchwork_comment" ADD COLUMN "parent_id" integer NULL;
+ALTER TABLE "patchwork_comment" ADD CONSTRAINT parent_id_refs_id_7b721867
+        FOREIGN KEY ("parent_id")
+        REFERENCES "patchwork_comment" ("id")
+        DEFERRABLE INITIALLY DEFERRED;
+COMMIT;
diff --git a/lib/sql/migration/006-maintainer-project-attributes.sql b/lib/sql/migration/006-maintainer-project-attributes.sql
new file mode 100644 (file)
index 0000000..86b82e1
--- /dev/null
@@ -0,0 +1,22 @@
+BEGIN;
+
+CREATE TABLE "patchwork_projectmaintainer" (                                    
+    "id" serial NOT NULL PRIMARY KEY,
+    "project_id" integer NOT NULL
+        REFERENCES "patchwork_project" ("id") DEFERRABLE INITIALLY DEFERRED,
+    "user_id" integer NOT NULL
+        REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
+    "master" boolean NOT NULL
+);
+
+INSERT INTO patchwork_projectmaintainer
+    (project_id, user_id, master)
+    SELECT project_id, patchwork_userprofile.user_id, False
+        FROM patchwork_userprofile_maintainer_projects
+        INNER JOIN patchwork_userprofile
+            ON patchwork_userprofile.id =
+                patchwork_userprofile_maintainer_projects.userprofile_id;
+
+--DROP TABLE patchwork_userprofile_maintainer_projects;
+
+COMMIT;