mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
21 lines
692 B
TypeScript
21 lines
692 B
TypeScript
import { Kysely, sql } from 'kysely';
|
|
|
|
export async function up(qb: Kysely<any>): Promise<void> {
|
|
type Conf = { db: string; guc: string[] };
|
|
const res = await sql<Conf>`select current_database() db, to_json(setconfig) guc from pg_db_role_setting`.execute(qb);
|
|
if (res.rows.length === 0) {
|
|
return;
|
|
}
|
|
|
|
const { db, guc } = res.rows[0];
|
|
await sql.raw(`alter database "${db}" reset all;`).execute(qb);
|
|
for (const parameter of guc) {
|
|
const [key, value] = parameter.split('=');
|
|
if (key === 'vchordrq.prewarm_dim') {
|
|
continue;
|
|
}
|
|
await sql.raw(`alter database "${db}" set ${key} to ${value};`).execute(qb);
|
|
}
|
|
}
|
|
|
|
export async function down(): Promise<void> {}
|