mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
More sequence tweaks
This commit is contained in:
parent
121f197625
commit
92ea4e5a80
|
|
@ -66,16 +66,9 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
return fmt.Errorf("tx.Exec: %w", err)
|
||||
}
|
||||
_, err := tx.Exec(`
|
||||
DROP SEQUENCE IF EXISTS roomserver_state_block_nid_seq;
|
||||
DROP SEQUENCE IF EXISTS roomserver_state_snapshot_nid_seq;
|
||||
`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("tx.Exec (drop sequences): %w", err)
|
||||
}
|
||||
_, err = tx.Exec(`
|
||||
CREATE SEQUENCE roomserver_state_block_nid_seq START WITH $1;
|
||||
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_seq'),
|
||||
state_block_nid bigint PRIMARY KEY DEFAULT nextval('roomserver_state_block_nid_sequence'),
|
||||
state_block_hash BYTEA UNIQUE,
|
||||
event_nids bigint[] NOT NULL
|
||||
);
|
||||
|
|
@ -84,9 +77,9 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
return fmt.Errorf("tx.Exec (create blocks table): %w", err)
|
||||
}
|
||||
_, err = tx.Exec(`
|
||||
CREATE SEQUENCE roomserver_state_snapshot_nid_seq START WITH $1;
|
||||
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_seq'),
|
||||
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
|
||||
|
|
@ -199,10 +192,16 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
}
|
||||
}
|
||||
|
||||
if _, err = tx.Exec(`DROP TABLE _roomserver_state_snapshots;`); err != nil {
|
||||
if _, err = tx.Exec(`
|
||||
DROP TABLE _roomserver_state_snapshots;
|
||||
DROP SEQUENCE roomserver_state_snapshots_nid_seq;
|
||||
`); err != nil {
|
||||
return fmt.Errorf("tx.Exec (delete old snapshot table): %w", err)
|
||||
}
|
||||
if _, err = tx.Exec(`DROP TABLE _roomserver_state_block;`); err != nil {
|
||||
if _, err = tx.Exec(`
|
||||
DROP TABLE _roomserver_state_block;
|
||||
DROP SEQUENCE roomserver_state_block_nid_seq;
|
||||
`); err != nil {
|
||||
return fmt.Errorf("tx.Exec (delete old block table): %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue