messing stuff up

This commit is contained in:
2025-06-03 20:46:11 -05:00
parent e3ee3e6708
commit e8acd6bb20
25 changed files with 300 additions and 51 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
# Wait for the database service to be ready
# 1) Wait for the database service to be ready
DB_HOST=${DB_HOST:-db}
DB_PORT=${DB_PORT:-3306}
echo "[⏳] Waiting for database at $DB_HOST:$DB_PORT..."
@ -10,22 +10,30 @@ until nc -z $DB_HOST $DB_PORT; do
done
echo "[✔] Database is up and reachable"
# Initialize migrations folder if needed
if [ ! -d migrations ]; then
echo "[] Initializing migrations directory"
flask db init
# If theres no migrations folder yet, initialize Alembic here:
if [ ! -d "./migrations" ]; then
echo "[🆕] No migrations directory found; initializing Alembic"
flask db init
fi
echo "[✔] Running migrations"
flask db migrate -m "auto"
# 2) Always apply any already-created migration scripts first
echo "[▶️] Applying existing migrations (upgrade)"
flask db upgrade
# Seed database if enabled (accept “1” or “true”)
# 3) Now attempt to autogenerate a new migration if the models changed
echo "[✨] Autogenerating new migration (if needed)"
flask db migrate -m "auto"
# 4) Apply that new migration (if one was generated)
echo "[▶️] Applying any newly autogenerated migration"
flask db upgrade
# 5) Optionally seed data
if [ "$ENABLE_DB_SEEDING" = "true" ] || [ "$ENABLE_DB_SEEDING" = "1" ]; then
echo "[🌱] Seeding Data"
flask preload-data
echo "[🌱] Seeding Data"
flask preload-data
fi
# Start the main process
# 6) Finally, run the Flask application
echo "[🚀] Starting Flask"
exec "$@"