From 192e5a259a47336af5fce2d72107f605caee7b9a Mon Sep 17 00:00:00 2001
From: Jeremy Kerr <jk@ozlabs.org>
Date: Fri, 27 Feb 2009 13:40:49 +1100
Subject: migration: reset bundlepatch sequence on setup

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

(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
index f6e37eb..3f0ad13 100644
--- a/lib/sql/migration/005-bundle-patch-ordering.sql
+++ b/lib/sql/migration/005-bundle-patch-ordering.sql
@@ -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
-- 
cgit v1.2.3

