mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
23 lines
579 B
Bash
Executable File
23 lines
579 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Initialise the XAMXAM 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"
|