Create sequence if not exists

This commit is contained in:
Neil Alexander 2021-04-21 09:49:54 +01:00
parent 8859e0e86b
commit cdf8126254
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 2 additions and 2 deletions

View file

@ -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,

View file

@ -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,