Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/database/migration-config.js
Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | async () => { | ||||
ALTER TABLE olm_sessions | ALTER TABLE olm_sessions | ||||
ADD PRIMARY KEY (cookie_id, is_content); | ADD PRIMARY KEY (cookie_id, is_content); | ||||
`, | `, | ||||
{ multipleStatements: true }, | { multipleStatements: true }, | ||||
); | ); | ||||
}, | }, | ||||
], | ], | ||||
[ | |||||
34, | |||||
async () => { | |||||
await dbQuery( | |||||
SQL` | |||||
CREATE TABLE IF NOT EXISTS olm_accounts ( | |||||
is_content tinyint(1) NOT NULL, | |||||
version bigint(20) 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()); | const newDatabaseVersion: number = Math.max(...migrations.keys()); | ||||
async function writeJSONToFile(data: any, filePath: string): Promise<void> { | async function writeJSONToFile(data: any, filePath: string): Promise<void> { | ||||
console.warn(`updating ${filePath} to ${JSON.stringify(data)}`); | console.warn(`updating ${filePath} to ${JSON.stringify(data)}`); | ||||
const fileHandle = await fs.promises.open(filePath, 'w'); | const fileHandle = await fs.promises.open(filePath, 'w'); | ||||
await fileHandle.writeFile(JSON.stringify(data, null, ' '), 'utf8'); | await fileHandle.writeFile(JSON.stringify(data, null, ' '), 'utf8'); | ||||
await fileHandle.close(); | await fileHandle.close(); | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |