43 lines
1.0 KiB
Bash
Executable File
43 lines
1.0 KiB
Bash
Executable File
#!/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
|
|
|