2023-03-26 11:37:20 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
dbdir=$(dirname "$0")
|
|
|
|
db="$dbdir/radiostasis.db"
|
|
|
|
|
|
|
|
if ! command -v sqlite3 &>/dev/null; then
|
|
|
|
echo "sqlite3 not found on path"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$db" ]; then
|
|
|
|
echo -n "radiostasis.db already exists, delete and continue? [Y/n] "
|
|
|
|
read -r answer
|
|
|
|
if [[ "$answer" =~ ^[Nn]$ ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
rm "$db"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-04-05 13:39:49 -05:00
|
|
|
for sql in "$dbdir"/migrations/*.sql; do
|
2023-03-26 11:37:20 -05:00
|
|
|
echo "$sql..."
|
|
|
|
sqlite3 radiostasis.db < "$sql"
|
|
|
|
done
|
|
|
|
echo "Done."
|