From cdf812625458e7fb2a0822dc5773e4dc22236354 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 21 Apr 2021 09:49:54 +0100 Subject: [PATCH] Create sequence if not exists --- roomserver/storage/postgres/state_block_table.go | 2 +- roomserver/storage/postgres/state_snapshot_table.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roomserver/storage/postgres/state_block_table.go b/roomserver/storage/postgres/state_block_table.go index 7c785060f..6784e84ff 100644 --- a/roomserver/storage/postgres/state_block_table.go +++ b/roomserver/storage/postgres/state_block_table.go @@ -39,7 +39,7 @@ const stateDataSchema = ` -- lookup a specific (type, state_key) pair for an event. It also makes it easy -- to read the state for a given state_block_nid ordered by (type, state_key) -- which in turn makes it easier to merge state data blocks. -CREATE SEQUENCE roomserver_state_block_nid_seq START AT $1; +CREATE SEQUENCE IF NOT EXISTS roomserver_state_block_nid_seq; CREATE TABLE IF NOT EXISTS roomserver_state_block ( state_block_nid bigint PRIMARY KEY DEFAULT nextval('roomserver_state_block_nid_seq'), state_block_hash BYTEA UNIQUE, diff --git a/roomserver/storage/postgres/state_snapshot_table.go b/roomserver/storage/postgres/state_snapshot_table.go index c6f72a829..037064a4d 100644 --- a/roomserver/storage/postgres/state_snapshot_table.go +++ b/roomserver/storage/postgres/state_snapshot_table.go @@ -39,7 +39,7 @@ const stateSnapshotSchema = ` -- because room state tends to accumulate small changes over time. Although if -- the list of deltas becomes too long it becomes more efficient to encode -- the full state under single state_block_nid. -CREATE SEQUENCE roomserver_state_snapshot_nid_seq START AT $1; +CREATE SEQUENCE IF NOT EXISTS roomserver_state_snapshot_nid_seq; CREATE TABLE IF NOT EXISTS roomserver_state_snapshots ( state_snapshot_nid bigint PRIMARY KEY DEFAULT nextval('roomserver_state_snapshot_nid_seq'), state_snapshot_hash BYTEA UNIQUE,