// Knex configuration for the migration framework.
// Reads DB_PATH from env (with a sane default for local dev) and points
// at the migrations/ + seeds/ directories under server/src/database/.

const path = require('path');

const DB_PATH = process.env.DB_PATH || path.join(__dirname, 'data', 'school.db');

module.exports = {
  client: 'better-sqlite3',
  connection: { filename: DB_PATH },
  useNullAsDefault: true,
  migrations: {
    directory: path.join(__dirname, 'src', 'database', 'migrations', 'knex'),
    tableName: 'knex_migrations',
  },
  seeds: {
    directory: path.join(__dirname, 'src', 'database', 'seeds'),
  },
  pool: {
    // Single connection — better-sqlite3 is synchronous and a single
    // shared connection is the standard pattern.
    min: 1,
    max: 1,
  },
};
