Skip to content
Snippets Groups Projects
RunMigration.sh 630 B
Newer Older
#!/bin/bash -e

action=$1
export ENV=$2
export FLASK_APP=../app.py
export FLASK_DB_BINDING_TO_MIGRATE=$3
migrations_dir_path="$ENV/$FLASK_DB_BINDING_TO_MIGRATE"

if [ "$action" = "upgrade" ]; then
	flask db init --directory $migrations_dir_path
	flask db migrate -m "In this migration we did..." --directory $migrations_dir_path
elif [ "$action" != "downgrade" ]; then 
	read -p "Invalid action specified: $action"
	exit -1
fi


input_prompt="Press any key to confirm and $action the migration..."
read -p "$input_prompt"
read -p "$input_prompt"
flask db $action --directory $migrations_dir_path
read -p "Press any key to exit."