From e1902ae697cf243c9171811c528b07d56cd97cfc Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 21 Apr 2021 10:25:50 +0100 Subject: [PATCH] Query parameters are not playing the game --- .../deltas/2021041615092700_state_blocks_refactor.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roomserver/storage/postgres/deltas/2021041615092700_state_blocks_refactor.go b/roomserver/storage/postgres/deltas/2021041615092700_state_blocks_refactor.go index ae5cfd309..f7c595071 100644 --- a/roomserver/storage/postgres/deltas/2021041615092700_state_blocks_refactor.go +++ b/roomserver/storage/postgres/deltas/2021041615092700_state_blocks_refactor.go @@ -65,26 +65,30 @@ func UpStateBlocksRefactor(tx *sql.Tx) error { if _, err := tx.Exec(`ALTER TABLE roomserver_state_snapshots RENAME TO _roomserver_state_snapshots;`); err != nil { return fmt.Errorf("tx.Exec: %w", err) } + if _, err := tx.Exec(`CREATE SEQUENCE roomserver_state_block_nid_sequence START WITH $1;`, maxblockid); err != nil { + return fmt.Errorf("tx.Exec: %w", err) + } + if _, err := tx.Exec(`CREATE SEQUENCE roomserver_state_snapshot_nid_sequence START WITH $1;`, maxsnapshotid); err != nil { + return fmt.Errorf("tx.Exec: %w", err) + } _, err := tx.Exec(` - CREATE SEQUENCE roomserver_state_block_nid_sequence START WITH $1; CREATE TABLE IF NOT EXISTS roomserver_state_block ( state_block_nid bigint PRIMARY KEY DEFAULT nextval('roomserver_state_block_nid_sequence'), state_block_hash BYTEA UNIQUE, event_nids bigint[] NOT NULL ); - `, maxblockid) + `) if err != nil { return fmt.Errorf("tx.Exec (create blocks table): %w", err) } _, err = tx.Exec(` - CREATE SEQUENCE roomserver_state_snapshot_nid_sequence START WITH $1; CREATE TABLE IF NOT EXISTS roomserver_state_snapshots ( state_snapshot_nid bigint PRIMARY KEY DEFAULT nextval('roomserver_state_snapshot_nid_sequence'), state_snapshot_hash BYTEA UNIQUE, room_nid bigint NOT NULL, state_block_nids bigint[] NOT NULL ); - `, maxsnapshotid) + `) if err != nil { return fmt.Errorf("tx.Exec (create snapshots table): %w", err) }