Release migrations

This commit is contained in:
datalets 2021-03-16 11:33:52 +01:00
parent a98bb59cf2
commit 04a344fa8e
3 changed files with 14 additions and 2 deletions

View File

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

View File

@ -186,7 +186,9 @@ Dark Bootswatch themes do not play well with the *navbar-light* component used i
### Cannot upgrade database
In local deployment, you will need to upgrade the database using `./manage.py db upgrade`. On Heroku, a deployment process called **Release** runs automatically. If you get errors like *ERROR [alembic.env] Can't locate revision identified by 'aa969b4f9f51'*, usually the fix is to drop the migration history table (`psql -c "drop table alembic_version"`), and again `db init .. db migrate .. db upgrade`. You can also do this in your database client.
In local deployment, you will need to upgrade the database using `./manage.py db upgrade`. On Heroku, a deployment process called **Release** runs automatically.
If you get errors like *ERROR [alembic.env] Can't locate revision identified by 'aa969b4f9f51'*, your migration history is out of sync. You can just set `FORCE_MIGRATE` to 1 when you run releases.
See also instructions in the `force-migrate.sh` script.

10
release.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# Release script
if [ "$FORCE_MIGRATE" ]; then
./force-migrate.sh psql
else
# Silent upgrade
python manage.py db upgrade 2>&1 >/dev/null
fi