X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=lib%2Fsql%2Fmigration%2F005-bundle-patch-ordering.sql;h=cd2183a83e3ca8b824b81d11734cd84a04d5add1;hb=0228487cc4e6709b29a1e34817513380f2cd4a72;hp=f6e37eb01853513d0c23aa4c3162e686885ed0cd;hpb=17e39712c3f9398f4aa6aae9f368f642af615eab;p=patchwork diff --git a/lib/sql/migration/005-bundle-patch-ordering.sql b/lib/sql/migration/005-bundle-patch-ordering.sql index f6e37eb..cd2183a 100644 --- a/lib/sql/migration/005-bundle-patch-ordering.sql +++ b/lib/sql/migration/005-bundle-patch-ordering.sql @@ -1,5 +1,5 @@ BEGIN; -CREATE TABLE "patchwork_bundlepatch" ( +CREATE TABLE "patchwork_bundlepatch" ( "id" SERIAL NOT NULL PRIMARY KEY, "patch_id" INTEGER NOT NULL REFERENCES "patchwork_patch" ("id") DEFERRABLE INITIALLY DEFERRED, @@ -23,6 +23,10 @@ BEGIN; ALTER TABLE patchwork_bundlepatch ALTER COLUMN "order" TYPE INTEGER; +-- initialise the starting number for this sequence +SELECT setval('patchwork_bundlepatch_id_seq', + (SELECT max(id) + 1 FROM patchwork_bundlepatch)); + DROP TABLE patchwork_bundle_patches; -- normalise ordering: order should start with 1 in each bundle