blob: dee94110894c42a76f38198eec6347963f770726 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { createClient } from '@libsql/client';
import { readdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
const dbUrl = process.env.DATABASE_URL ?? 'file:./data/data.db';
const client = createClient({ url: dbUrl });
const dir = '/app/drizzle';
const files = readdirSync(dir)
.filter((f) => f.endsWith('.sql'))
.sort();
for (const file of files) {
const sql = readFileSync(join(dir, file), 'utf8');
const stmts = sql.split('--> statement-breakpoint').filter(Boolean);
for (const stmt of stmts) {
await client.execute(stmt);
}
}
console.log(`${files.length} migration(s) applied.`);
client.close();
|