diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js --- a/keyserver/src/database/migration-config.js +++ b/keyserver/src/database/migration-config.js @@ -284,15 +284,15 @@ async () => { await dbQuery( SQL` - CREATE TABLE IF NOT EXISTS message_search ( - original_message_id bigint(20) NOT NULL, - message_id bigint(20) NOT NULL, - processed_content mediumtext COLLATE utf8mb4_bin - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + CREATE TABLE IF NOT EXISTS message_search ( + original_message_id bigint(20) NOT NULL, + message_id bigint(20) NOT NULL, + processed_content mediumtext COLLATE utf8mb4_bin + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; - ALTER TABLE message_search - ADD PRIMARY KEY (original_message_id), - ADD FULLTEXT INDEX processed_content (processed_content); + ALTER TABLE message_search + ADD PRIMARY KEY (original_message_id), + ADD FULLTEXT INDEX processed_content (processed_content); `, { multipleStatements: true }, ); @@ -360,6 +360,27 @@ `); }, ], + [ + 33, + async () => { + await dbQuery( + SQL` + CREATE TABLE IF NOT EXISTS olm_sessions ( + cookie_id bigint(20) NOT NULL, + is_content tinyint(1) NOT NULL, + version bigint(20) NTO NULL, + pickled_olm_session text + CHARACTER SET latin1 + COLLATE latin1_bin NOT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + + ALTER TABLE olm_sessions + ADD PRIMARY KEY (cookie_id, is_content); + `, + { multipleStatements: true }, + ); + }, + ], ]); const newDatabaseVersion: number = Math.max(...migrations.keys()); diff --git a/keyserver/src/database/setup-db.js b/keyserver/src/database/setup-db.js --- a/keyserver/src/database/setup-db.js +++ b/keyserver/src/database/setup-db.js @@ -260,6 +260,15 @@ number_of_uses int UNSIGNED NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE olm_sessions ( + cookie_id bigint(20) NOT NULL, + is_content tinyint(1) NOT NULL, + version bigint(20) NOT NULL, + pickled_olm_session text + CHARACTER SET ascii + COLLATE latin1_bin NOT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + ALTER TABLE cookies ADD PRIMARY KEY (id), ADD UNIQUE KEY device_token (device_token(512)), @@ -384,6 +393,9 @@ ADD PRIMARY KEY (id), ADD UNIQUE KEY (name), ADD INDEX community_primary (community, \`primary\`); + + ALTER TABLE olm_sessions + ADD PRIMARY KEY (cookie_id, is_content); `, { multipleStatements: true }, );