#!/bin/sh
set -eu

project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
database="$project_dir/public/assets/scoreboard-backup.sqlite"
seed="$project_dir/treasure/scoreboard-backup.sql"

mkdir -p "$project_dir/public/assets"
rm -f "$database"
sqlite3 "$database" < "$seed"
sqlite3 "$database" "PRAGMA integrity_check;" | grep -qx "ok"
sqlite3 "$database" \
  "SELECT value FROM treasure_chest WHERE slot = 42;" \
  | grep -qx 'KP{SELECT_STAR_BUT_VERIFY_FIRST}'
sqlite3 "$database" \
  "SELECT value FROM treasure_chest WHERE slot = 1987;" \
  | grep -qx 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
