diff --git a/scripts/db_squash.sh b/scripts/db_squash.sh new file mode 100755 index 0000000..23f79b8 --- /dev/null +++ b/scripts/db_squash.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Usage: ./db_migrate.sh -m "Your migration message" -d migrations/public + +# Load environment variables +set -a +source .env +set +a + +project_dir=$(pwd) +# Ensure you're in the correct directory +cd "$project_dir" || exit 1 + +# Load environment variables (including database connection details) +source .env + +# Set Flask app and Python path +export FLASK_APP=scripts/run_eveai_app.py +export PYTHONPATH="$PYTHONPATH:$project_dir" + +while getopts m: flag +do + case "${flag}" in + m) message=${OPTARG};; + *) + echo "Invalid option: ${flag}" + exit 1 + ;; + esac +done + +# Check if the message and directory are provided +if [ -z "$message" ]; then + echo "Message is required." + echo "Usage: ./db_migrate.sh -m \"Your migration message\" -d migrations/public" + exit 1 +fi + +# Run the alembic commands +flask db revision --autogenerate -m "Consolidated Public Migrations - $message" -d migrations/public +flask db revision --autogenerate -m "Consolidated Tenant Migrations - $message" -d migrations/tenant + diff --git a/scripts/start_eveai_app.sh b/scripts/start_eveai_app.sh index 541783b..7d3bee2 100755 --- a/scripts/start_eveai_app.sh +++ b/scripts/start_eveai_app.sh @@ -32,10 +32,12 @@ export PYTHONPATH="$PROJECT_DIR/patched_packages:$PYTHONPATH:$PROJECT_DIR" # In # Run Alembic upgrade for the public schema echo "Applying migrations to the public schema..." flask db upgrade -d "${PROJECT_DIR}/migrations/public" +echo "Finished applying migrations to the public schema..." # Run Alembic upgrade for the tenant schema echo "Applying migrations to the tenant schema..." flask db upgrade -d "${PROJECT_DIR}/migrations/tenant" +echo "Finished applying migrations to the tenant schema..." # Set flask environment variables #export FLASK_ENV=development # Use 'production' as appropriate