Add 21 files, update 16 files, rename 1 file
This commit is contained in:
1 parent
b9e4ed4dfc
commit
278293b397
39 files changed
+2434
-61
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { access, mkdir } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
|
||||
if (!databaseUrl?.startsWith('file:')) {
|
||||
throw new Error('DATABASE_URL must use a SQLite file: URL');
|
||||
}
|
||||
|
||||
const databasePath = path.resolve(databaseUrl.slice('file:'.length));
|
||||
await mkdir(path.dirname(databasePath), { recursive: true });
|
||||
|
||||
const result = spawnSync('sqlite3', [databasePath, 'PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL; PRAGMA foreign_keys=ON; PRAGMA wal_checkpoint(TRUNCATE);'], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
if (result.error || result.status !== 0) {
|
||||
throw result.error ?? new Error(result.stderr || 'Unable to configure SQLite WAL mode');
|
||||
}
|
||||
|
||||
await access(databasePath);
|
||||
console.log(`SQLite WAL configured: ${databasePath}`);
|
||||
Reference in new issue
Block a user