Remove upgrade script

This commit is contained in:
Oleg Lavrovsky 2021-03-15 22:02:10 +01:00
parent b7700f7f5d
commit 559bce2bda
3 changed files with 23 additions and 18 deletions

View File

@ -1,2 +1,2 @@
web: gunicorn dribdat.app:init_app\(\) -b 0.0.0.0:$PORT -w 3 --log-file=-
release: ./upgrade.sh
release: python manage.py db upgrade

View File

@ -1,5 +1,17 @@
#!/bin/bash
if [ "$1" = "heroku" ]; then
# Run without arguments or scroll down for instructions
if [ "$1" = "psql" ]; then
echo "Force migrating database"
rm -rf migrations/
psql -c "DROP TABLE alembic_version;" $DATABASE_URL
python manage.py db init 2>&1 >/dev/null
python manage.py db migrate
python manage.py db upgrade
sleep 2
echo "Upgrade complete"
elif [ "$1" = "heroku" ]; then
if [ -z "$2" ]; then
echo "Specify the app you wish to upgrade as a second parameter."
exit
@ -8,12 +20,17 @@ if [ "$1" = "heroku" ]; then
sleep 5s
heroku pg:psql -a $2 -c "drop table alembic_version"
heroku run -a $2 "python manage.py db init && python manage.py db migrate && python manage.py db upgrade"
else
echo "Resetting local DB in 5 seconds - Ctrl-C to abort."
echo "(Use 'heroku' argument to migrate Heroku instance)"
sleep 5s
elif [ "$1" = "local" ]; then
echo "Resetting local SQLite DB (dev.db)"
rm -rf dev.db migrations
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
else
echo "Use this script to refresh the DB schema:"
echo "- in production (such as Heroku console), with the psql argument"
echo "- use the heroku argument to modify a locally configured remote app"
echo "- without arguments, it will ask you if you want to reset your SQLite DB"
fi

View File

@ -1,12 +0,0 @@
# Use this script to refresh the DB schema
if [ "$FORCE_MIGRATE" ]; then
echo "Force migrating database"
rm -rf migrations/
psql -c "DROP TABLE alembic_version;" $DATABASE_URL
python manage.py db init 2>&1 >/dev/null
python manage.py db migrate
fi
echo "Upgrading database"
python manage.py db upgrade
sleep 2
echo "Upgrade complete"