Commit 9b5c682e authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

Complete bundle ordering migration script


Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent c105cb0f
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;
CREATE SEQUENCE bundlepatch_tmp_seq;
ALTER TABLE patchwork_bundlepatch
ADD COLUMN "order" INTEGER NOT NULL
DEFAULT nextval('bundlepatch_tmp_seq');
ALTER TABLE patchwork_bundlepatch ALTER COLUMN "order" DROP DEFAULT;
DROP SEQUENCE bundlepatch_tmp_seq;
ALTER TABLE patchwork_bundlepatch ADD UNIQUE("bundle_id", "order");
COMMIT;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment