From c105cb0f107a7459abc8c33988d2da24582a7a5a Mon Sep 17 00:00:00 2001
From: Jeremy Kerr <jk@ozlabs.org>
Date: Thu, 29 Jan 2009 17:38:46 +1100
Subject: Initial bundle reordering support

todo:
 * implement ajax reorder api
 * finish migration script
 * order patches in bundle view

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 lib/sql/migration/005-bundle-patch-ordering.sql | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 lib/sql/migration/005-bundle-patch-ordering.sql

(limited to 'lib/sql/migration/005-bundle-patch-ordering.sql')

diff --git a/lib/sql/migration/005-bundle-patch-ordering.sql b/lib/sql/migration/005-bundle-patch-ordering.sql
new file mode 100644
index 0000000..9f5bcf3
--- /dev/null
+++ b/lib/sql/migration/005-bundle-patch-ordering.sql
@@ -0,0 +1,9 @@
+BEGIN;
+ALTER TABLE patchwork_bundle_patches RENAME TO patchwork_bundlepatch;
+ALTER TABLE patchwork_bundlepatch ADD COLUMN "order" INTEGER NULL;
+UPDATE patchwork_bundlepatch SET "order" =
+    (SELECT COALESCE(max("order"), 0) + 1 FROM patchwork_bundlepatch AS p2
+        WHERE p2.bundle_id = patchwork_bundlepatch.bundle_id);
+ALTER TABLE patchwork_bundlepatch ALTER COLUMN "order" SET NOT NULL;
+ALTER TABLE patchwork_bundlepatch ADD UNIQUE("bundle_id", "order");
+COMMIT;
-- 
cgit v1.2.3

