broke currently

This commit is contained in:
2025-06-22 16:11:29 -05:00
parent e7a0f5b1be
commit 2bb7a29141
77 changed files with 1748 additions and 2298 deletions

View File

@ -1,39 +1,51 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
# 1) Wait for the database service to be ready
UPLOAD_DIR="/app/static/uploads"
mkdir -p "$UPLOAD_DIR"
chown -R 1000:998 "$UPLOAD_DIR"
chmod -R 775 "$UPLOAD_DIR"
DB_HOST=${DB_HOST:-db}
DB_PORT=${DB_PORT:-3306}
echo "[⏳] Waiting for database at $DB_HOST:$DB_PORT..."
until nc -z $DB_HOST $DB_PORT; do
until nc -z "$DB_HOST" "$DB_PORT"; do
sleep 1
done
echo "[✔] Database is up and reachable"
echo "[✔] Database is up"
# If theres no migrations folder yet, initialize Alembic here:
# Initialize Alembic if not present
if [ ! -d "./migrations" ]; then
echo "[🆕] No migrations directory found; initializing Alembic"
flask db init
echo "[🆕] Generating initial migration"
flask db migrate -m "initial" || echo "[] Nothing to migrate"
fi
# 2) Always apply any already-created migration scripts first
echo "[] Applying existing migrations (upgrade)"
# Autogenerate new migration if needed
echo "[🛠] Checking for new schema changes"
if ! flask db migrate -m "auto-migrate" --compare-type --render-as-batch; then
echo "[] No schema changes detected"
fi
# Apply migrations
echo "[▶️] Applying database migrations"
flask db upgrade
# 3) Now attempt to autogenerate a new migration if the models changed
echo "[] Autogenerating new migration (if needed)"
flask db migrate -m "auto"
# Create any missing tables (edge case fallback)
echo "[🔧] Running db.create_all() to ensure full sync"
python <<EOF
from app import create_app, db
app = create_app()
with app.app_context():
db.create_all()
EOF
# 4) Apply that new migration (if one was generated)
echo "[▶️] Applying any newly autogenerated migration"
flask db upgrade
# 5) Optionally seed data
# Optional seeding
if [ "$ENABLE_DB_SEEDING" = "true" ] || [ "$ENABLE_DB_SEEDING" = "1" ]; then
echo "[🌱] Seeding Data"
flask preload-data
fi
# 6) Finally, run the Flask application
echo "[🚀] Starting Flask"
exec "$@"