import { Database } from 'sqlite3';
import path from 'path';
import fs from 'fs';

const dbPath = path.join(__dirname, '..', '..', 'data', 'app.db');
const db = new Database(dbPath);

const sql = fs.readFileSync(path.join(__dirname, 'schema.sql'), 'utf-8');

db.serialize(() => {
  db.exec(sql, (err) => {
    if (err) {
      console.error('Error applying schema:', err);
      process.exit(1);
    }
    console.log('Database schema applied successfully');
    db.close();
  });
});
