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 @@ -367,6 +367,24 @@ ); }, ], + [ + 33, + async () => { + await dbQuery( + SQL` + CREATE TABLE IF NOT EXISTS olm_accounts ( + is_content tinyint(1) NOT NULL, + pickling_key text CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, + pickled_olm_account text CHARACTER SET latin1 COLLATE latin1_bin NOT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + + ALTER TABLE olm_accounts + ADD PRIMARY KEY (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 @@ -266,6 +266,12 @@ pickled_olm_session text CHARACTER SET ascii COLLATE latin1_bin NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + CREATE TABLE olm_accounts ( + is_content tinyint(1) NOT NULL, + pickling_key text CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, + pickled_olm_account text CHARACTER SET latin1 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)), @@ -393,6 +399,9 @@ ALTER TABLE olm_sessions ADD PRIMARY KEY (cookie_id, is_content); + + ALTER TABLE olm_accounts + ADD PRIMARY KEY (is_content); `, { multipleStatements: true }, );