Skip to content

Commit

Permalink
db: try again to fix migrations
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Sep 17, 2024
1 parent f4f7ac0 commit c7a67e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 58 deletions.
29 changes: 12 additions & 17 deletions database/00-latest-revision.sql
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
-- v0 -> v2: Latest revision

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

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

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

CREATE TABLE IF NOT EXISTS room_members (
room_id VARCHAR(255),
user_id VARCHAR(255),
room_id TEXT,
user_id TEXT,
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,
matrix_room_id TEXT UNIQUE,
chatwoot_conversation_id INTEGER UNIQUE,
most_recent_event_id TEXT,
PRIMARY KEY (matrix_room_id, chatwoot_conversation_id)
);

CREATE TABLE IF NOT EXISTS chatwoot_message_to_matrix_event (
matrix_event_id VARCHAR(255) UNIQUE,
matrix_event_id TEXT,
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;
40 changes: 0 additions & 40 deletions database/01-initial-tables.sql

This file was deleted.

3 changes: 2 additions & 1 deletion database/02-migrate-to-mautrix-store.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- v2: Migrate to mautrix crypto store

-- Create all of the tables from the upstream mautrix crypto store
-- Create all of the tables from the upstream mautrix crypto store.
-- This is only necessary for old installations of the chatwoot bot.

CREATE TABLE mx_registrations (
user_id TEXT PRIMARY KEY
Expand Down

0 comments on commit c7a67e6

Please sign in to comment.