Skip to content

Commit

Permalink
db: fix upgrades when creating from scratch
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Jul 3, 2024
1 parent cf0fe10 commit bdd548e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions database/00-latest-revision.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- v0 -> v2: Latest revision

CREATE TABLE IF NOT EXISTS user_filter_ids (
user_id VARCHAR(255) PRIMARY KEY,
filter_id VARCHAR(255)
);

CREATE TABLE IF NOT EXISTS user_batch_tokens (
user_id VARCHAR(255) PRIMARY KEY,
next_batch_token VARCHAR(255)
);

CREATE TABLE IF NOT EXISTS rooms (
room_id VARCHAR(255) PRIMARY KEY,
encryption_event VARCHAR(65535) NULL
);

CREATE TABLE IF NOT EXISTS room_members (
room_id VARCHAR(255),
user_id VARCHAR(255),
PRIMARY KEY (room_id, user_id)
);

CREATE TABLE IF NOT EXISTS chatwoot_conversation_to_matrix_room (
matrix_room_id VARCHAR(255) UNIQUE,
chatwoot_conversation_id INTEGER UNIQUE,
PRIMARY KEY (matrix_room_id, chatwoot_conversation_id)
);

CREATE TABLE IF NOT EXISTS chatwoot_message_to_matrix_event (
matrix_event_id VARCHAR(255) UNIQUE,
chatwoot_message_id INTEGER,
PRIMARY KEY (matrix_event_id, chatwoot_message_id)
);

ALTER TABLE chatwoot_conversation_to_matrix_room
ADD COLUMN IF NOT EXISTS most_recent_event_id VARCHAR(255);

ALTER TABLE chatwoot_message_to_matrix_event
DROP CONSTRAINT IF EXISTS chatwoot_message_to_matrix_event_matrix_event_id_key;
File renamed without changes.
File renamed without changes.

0 comments on commit bdd548e

Please sign in to comment.