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 275 Lines • ▼ Show 20 Lines | async () => { | ||||
ALTER TABLE message_search | ALTER TABLE message_search | ||||
ADD PRIMARY KEY (original_message_id), | ADD PRIMARY KEY (original_message_id), | ||||
ADD FULLTEXT INDEX processed_content (processed_content); | ADD FULLTEXT INDEX processed_content (processed_content); | ||||
`, | `, | ||||
{ multipleStatements: true }, | { multipleStatements: true }, | ||||
); | ); | ||||
}, | }, | ||||
], | ], | ||||
[26, 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 |