From: Jeremy Kerr Date: Sat, 7 Feb 2009 04:48:37 +0000 (+1100) Subject: Normalise order numbers in bundle-ordering migration SQL X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=5f20247c07c17d266321d49042c525deafe65152;p=patchwork Normalise order numbers in bundle-ordering migration SQL Signed-off-by: Jeremy Kerr --- diff --git a/lib/sql/migration/005-bundle-patch-ordering.sql b/lib/sql/migration/005-bundle-patch-ordering.sql index e0db398..1491aa8 100644 --- a/lib/sql/migration/005-bundle-patch-ordering.sql +++ b/lib/sql/migration/005-bundle-patch-ordering.sql @@ -8,4 +8,7 @@ ALTER TABLE patchwork_bundlepatch ALTER TABLE patchwork_bundlepatch ALTER COLUMN "order" DROP DEFAULT; DROP SEQUENCE bundlepatch_tmp_seq; ALTER TABLE patchwork_bundlepatch ADD UNIQUE("bundle_id", "order"); +UPDATE patchwork_bundlepatch SET "order" = 1 + "order" - + (SELECT min("order") FROM patchwork_bundlepatch AS p2 + WHERE p2.bundle_id = patchwork_bundlepatch.bundle_id); COMMIT;