update first - 84

This commit is contained in:
thanhnv
2026-06-30 02:21:39 +09:00
commit 07ac1bdcdd
561 changed files with 88164 additions and 0 deletions
@@ -0,0 +1,27 @@
import { mkdirSync, readFileSync, rmSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { DatabaseSync } from 'node:sqlite';
function databasePathFromUrl(url) {
if (!url?.startsWith('file:')) {
throw new Error('DATABASE_URL must use SQLite file: URL');
}
const rawPath = url.slice('file:'.length);
if (rawPath.startsWith('/')) {
return rawPath;
}
return resolve('prisma', rawPath);
}
const databasePath = databasePathFromUrl(process.env.DATABASE_URL ?? 'file:./dev.db');
mkdirSync(dirname(databasePath), { recursive: true });
rmSync(databasePath, { force: true });
rmSync(`${databasePath}-journal`, { force: true });
const sql = readFileSync(resolve('prisma/migrations/202606280001_init/migration.sql'), 'utf8');
const db = new DatabaseSync(databasePath);
db.exec('PRAGMA foreign_keys = ON;');
db.exec(sql);
db.close();
console.log(`SQLite schema applied to ${databasePath}`);