Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/database/migration-config.js
// @flow | // @flow | ||||
import fs from 'fs'; | import fs from 'fs'; | ||||
import { policyTypes } from 'lib/facts/policies.js'; | import { policyTypes } from 'lib/facts/policies.js'; | ||||
import { dbQuery, SQL } from '../database/database.js'; | import { dbQuery, SQL } from '../database/database.js'; | ||||
import { processMessagesInDBForSearch } from '../database/search_utils.js'; | |||||
import { updateRolesAndPermissionsForAllThreads } from '../updaters/thread-permission-updaters.js'; | import { updateRolesAndPermissionsForAllThreads } from '../updaters/thread-permission-updaters.js'; | ||||
const migrations: $ReadOnlyMap<number, () => Promise<void>> = new Map([ | const migrations: $ReadOnlyMap<number, () => Promise<void>> = new Map([ | ||||
[ | [ | ||||
0, | 0, | ||||
async () => { | async () => { | ||||
await makeSureBaseRoutePathExists('facts/commapp_url.json'); | await makeSureBaseRoutePathExists('facts/commapp_url.json'); | ||||
await makeSureBaseRoutePathExists('facts/squadcal_url.json'); | await makeSureBaseRoutePathExists('facts/squadcal_url.json'); | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | async () => { | ||||
processed_content mediumtext COLLATE utf8mb4_bin, | processed_content mediumtext COLLATE utf8mb4_bin, | ||||
FULLTEXT(processed_content), | FULLTEXT(processed_content), | ||||
PRIMARY KEY (original_message_id) | PRIMARY KEY (original_message_id) | ||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; | ||||
`, | `, | ||||
); | ); | ||||
}, | }, | ||||
], | ], | ||||
[22, processMessagesInDBForSearch], | |||||
]); | ]); | ||||
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 |