import fs from 'fs';
import Database from 'better-sqlite3';

const dbName = 'strimserve.db';

// Read the schema file
const schema = fs.readFileSync('schema.sql', 'utf8');

// Create a new database object and initialize it with the schema
const db = new Database(dbName);

try {
	console.log(`Connected to the ${dbName} database.`);
	db.exec(schema);
	console.log('Schema initialized successfully.');
} catch (err) {
	console.error(err.message);
} finally {
	db.close();
}
