diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sql/migration/005-bundle-patch-ordering.sql | 9 |
1 files changed, 9 insertions, 0 deletions
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; |