#!/bin/sh
set -eu

# AUTO_CREATE_SCHEMA=true is convenient for a first SQLite run. For production,
# set it to false and let Alembic own the schema. RUN_MIGRATIONS=true also
# forces a migration before the bot starts.
if [ "${RUN_MIGRATIONS:-false}" = "true" ] || [ "${AUTO_CREATE_SCHEMA:-true}" = "false" ]; then
    echo "Applying database migrations..."
    alembic upgrade head
fi

exec "$@"
