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 @@ -343,6 +343,24 @@ ); }, ], + [ + 32, + async () => { + await dbQuery( + SQL` + CREATE TABLE IF NOT EXISTS olm_accounts ( + is_primary tinyint(1) NOT NULL, + pickling_key text CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, + pickled_olm_account text CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + + ALTER TABLE olm_accounts + ADD PRIMARY KEY (is_primary); + `, + { 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 @@ -255,6 +255,12 @@ pickled_olm_session text CHARACTER SET ascii COLLATE latin1_bin DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + CREATE TABLE olm_accounts ( + is_primary tinyint(1) NOT NULL, + pickling_key text CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, + pickled_olm_account text CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + ALTER TABLE cookies ADD PRIMARY KEY (id), ADD UNIQUE KEY device_token (device_token(512)), @@ -377,6 +383,9 @@ ALTER TABLE olm_sessions ADD PRIMARY KEY (cookie_id, is_primary); + + ALTER TABLE olm_accounts + ADD PRIMARY KEY (is_primary); `, { multipleStatements: true }, );