#!/usr/bin/env bash # Initialise the Post-ERG SQLite database from schema.sql. # Safe to run on existing databases — schema uses IF NOT EXISTS / INSERT OR IGNORE. # Usage: # scripts/migrate.sh # xamxam.db (default) set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" APP_DIR="$REPO_ROOT/app" SCHEMA="$APP_DIR/storage/schema.sql" PROD_DB="$APP_DIR/storage/xamxam.db" init_db() { local db="$1" local label="$2" echo " [$label] applying schema…" sqlite3 "$db" < "$SCHEMA" echo " [$label] done" } init_db "$PROD_DB" "xamxam.db"