Reset sequences

This commit is contained in:
Neil Alexander 2020-12-11 12:59:41 +00:00
parent e7ada57dbb
commit 88685be9d2
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 2 additions and 0 deletions

View file

@ -39,6 +39,7 @@ func UpFixSequences(tx *sql.Tx) error {
-- Use the new syncapi_receipts_id sequence. -- Use the new syncapi_receipts_id sequence.
CREATE SEQUENCE IF NOT EXISTS syncapi_receipt_id; CREATE SEQUENCE IF NOT EXISTS syncapi_receipt_id;
ALTER SEQUENCE IF EXISTS syncapi_receipt_id RESTART WITH 1;
ALTER TABLE syncapi_receipts ALTER COLUMN id SET DEFAULT nextval('syncapi_receipt_id'); ALTER TABLE syncapi_receipts ALTER COLUMN id SET DEFAULT nextval('syncapi_receipt_id');
`) `)
if err != nil { if err != nil {

View file

@ -36,6 +36,7 @@ func UpFixSequences(tx *sql.Tx) error {
-- will be wrong, and we'll get primary key violations if we try to -- will be wrong, and we'll get primary key violations if we try to
-- reuse existing stream IDs from a different sequence. -- reuse existing stream IDs from a different sequence.
DELETE FROM syncapi_receipts; DELETE FROM syncapi_receipts;
UPDATE syncapi_stream_id SET stream_id=1 WHERE stream_name="receipt";
`) `)
if err != nil { if err != nil {
return fmt.Errorf("failed to execute upgrade: %w", err) return fmt.Errorf("failed to execute upgrade: %w", err)