# Runs once, on the playground's first start: the MySQL image runs the .sh files in /docker-entrypoint-initdb.d, and
# docker_process_sql is its own helper for running SQL as root while it sets the server up.
#   shop:      the sample shop.
#   practice:  the sample shop again, plus the practice tables of "Classic SQL Interview Problems". Kept apart so
#              chapters that create their own tables (accounts, payments, tickets) don't collide with them.
for db in shop practice; do
  echo "CREATE DATABASE IF NOT EXISTS $db" | docker_process_sql
  docker_process_sql --database="$db" < /seed/shop.sql
done
docker_process_sql --database=practice < /seed/practice.sql
