27 lines
477 B
Bash
Executable file
27 lines
477 B
Bash
Executable file
#!/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
|
|
|
|
for sql in "$dbdir"/migrations/*.sql; do
|
|
echo "$sql..."
|
|
sqlite3 radiostasis.db < "$sql"
|
|
done
|
|
echo "Done."
|