const Database = require('better-sqlite3');
const path = require('path');

const AUTH_DB_PATH = path.join(__dirname, 'auth.db');

const authDb = new Database(AUTH_DB_PATH);
authDb.pragma('journal_mode = WAL');

authDb.exec(`
  CREATE TABLE IF NOT EXISTS auth_credentials (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    email TEXT NOT NULL UNIQUE,
    password_hash TEXT NOT NULL,
    nocodb_user_id INTEGER NOT NULL
  );
`);

module.exports = { authDb };
