Files

15 lines
637 B
Bash
Executable File

#!/bin/bash
# Applies sql/content/migrations to the running local world DB, oldest first. Each migration
# records itself in `migrations` and skips when already there, so a re-run changes nothing.
set -euo pipefail
local_dir=$(cd "$(dirname "$0")" && pwd)
content="$local_dir/../../sql/content/migrations"
shopt -s nullglob
files=("$content"/*_world.sql)
[[ ${#files[@]} -gt 0 ]] || { echo "no migrations in $content"; exit 0; }
for file in "${files[@]}"; do
echo "applying ${file##*/}"
"$local_dir/compose.sh" exec -T db sh -c \
'MYSQL_PWD="$(cat /run/secrets/db_password)" exec mariadb -uvmangos mangos' < "$file"
done