-- Migration number: 0000 2024-01-04T08:37:46.641Z CREATE TABLE IF NOT EXISTS responses ( id INTEGER PRIMARY KEY ASC NOT NULL, tableId INTEGER NOT NULL CHECK (tableId IN (0, 1, 2, 3, 4, 5, 6)), text TEXT NOT NULL, timestamp INTEGER NOT NULL, userSnowflake TEXT NOT NULL, serverSnowflake TEXT NULL, access INTEGER NOT NULL CHECK (access IN (0, 1, 2)) ) STRICT; CREATE UNIQUE INDEX IF NOT EXISTS responses_unique_global ON responses (tableId, text) WHERE access = 0; CREATE UNIQUE INDEX IF NOT EXISTS responses_unique_by_server ON responses (serverSnowflake, tableId, text) WHERE access = 1; CREATE UNIQUE INDEX IF NOT EXISTS responses_unique_by_dm ON responses (userSnowflake, tableId, text) WHERE access = 2;