Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/database/migration-config.js
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | async () => { | ||||
await dbQuery(SQL` | await dbQuery(SQL` | ||||
ALTER TABLE threads | ALTER TABLE threads | ||||
ADD COLUMN IF NOT EXISTS avatar varchar(191) | ADD COLUMN IF NOT EXISTS avatar varchar(191) | ||||
COLLATE utf8mb4_bin | COLLATE utf8mb4_bin | ||||
DEFAULT NULL; | DEFAULT NULL; | ||||
`); | `); | ||||
}, | }, | ||||
], | ], | ||||
[ | |||||
21, | |||||
async () => { | |||||
await dbQuery( | |||||
SQL` | |||||
CREATE TABLE IF NOT EXISTS search ( | |||||
original_message_id bigint(20) NOT NULL, | |||||
message_id bigint(20) NOT NULL, | |||||
processed_content mediumtext COLLATE utf8mb4_bin, | |||||
FULLTEXT(processed_content), | |||||
PRIMARY KEY (original_message_id) | |||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; | |||||
`, | |||||
); | |||||
}, | |||||
], | |||||
]); | ]); | ||||
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 |