first commit
This commit is contained in:
commit
0e1ce93def
12 files changed
+1693
No files matched your search
+19
@@ -0,0 +1,19 @@
|
||||
// Creates tachyon.db (if it doesn't exist) and applies schema.sql.
|
||||
// Safe to re-run: every statement uses CREATE TABLE IF NOT EXISTS.
|
||||
import Database from 'better-sqlite3';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import path from 'node:path';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const dbPath = path.join(__dirname, 'tachyon.db');
|
||||
const schemaPath = path.join(__dirname, 'schema.sql');
|
||||
|
||||
const db = new Database(dbPath);
|
||||
db.pragma('journal_mode = WAL');
|
||||
|
||||
const schema = readFileSync(schemaPath, 'utf8');
|
||||
db.exec(schema);
|
||||
|
||||
console.log(`Initialized database at ${dbPath}`);
|
||||
db.close();
|
||||
Reference in new issue
Block a user