forked from noctf-project/noCTF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkysely.config.ts
More file actions
35 lines (32 loc) · 868 Bytes
/
kysely.config.ts
File metadata and controls
35 lines (32 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { defineConfig } from "kysely-ctl";
import type { MigrationProvider } from "kysely";
import { Pool } from "pg";
import { glob } from "node:fs/promises";
import { basename } from "node:path";
const MIGRATION_FILE_REGEX = /^[\d]+_.+\.ts$/;
class DevMigrationProvider implements MigrationProvider {
async getMigrations() {
const migrations = {};
for await (const filename of glob([
"migrations/*.ts",
"plugins/*/migrations/*.ts",
])) {
if (!basename(filename).match(MIGRATION_FILE_REGEX)) {
continue;
}
migrations[filename] = await import(`./${filename}`);
}
return migrations;
}
}
export default defineConfig({
dialect: "pg",
migrations: {
provider: new DevMigrationProvider(),
},
dialectConfig: {
pool: new Pool({
connectionString: process.env.POSTGRES_URL,
}),
},
});