mirror of
https://codeberg.org/dribdat/dribdat.git
synced 2026-03-18 17:46:20 +00:00
Update release scripts
This commit is contained in:
parent
e72ff1822c
commit
b74a8eda35
2 changed files with 24 additions and 11 deletions
|
|
@ -1,6 +1,13 @@
|
|||
#!/bin/bash
|
||||
# Run without arguments or scroll down for instructions
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
echo "This tool attempts to force your $1 database in sync with current Alembic schema."
|
||||
echo "Only use in case of problems: use the release.sh script for regular deployments."
|
||||
echo "!!!"
|
||||
echo "Pausing for 5 seconds - Ctrl-C to abort"; sleep 5s
|
||||
fi
|
||||
|
||||
if [ "$1" = "psql" ]; then
|
||||
echo "Force migrating database"
|
||||
rm -rf migrations/
|
||||
|
|
@ -8,28 +15,35 @@ if [ "$1" = "psql" ]; then
|
|||
python "${APPDIR:-.}/manage.py" db init 2>&1 >/dev/null
|
||||
python "${APPDIR:-.}/manage.py" db migrate
|
||||
python "${APPDIR:-.}/manage.py" db upgrade
|
||||
echo "Upgrade complete, 10 second cooldown"
|
||||
sleep 10
|
||||
echo "Upgrade complete"
|
||||
|
||||
elif [ "$1" = "heroku" ]; then
|
||||
if [ -z "$2" ]; then
|
||||
echo "Specify the app you wish to upgrade as a second parameter."
|
||||
exit
|
||||
fi
|
||||
echo "Migrating Heroku DB on $2 in 5 seconds - Ctrl-C to abort."
|
||||
sleep 5s
|
||||
echo "Migrating Heroku DB on $2"
|
||||
heroku pg:psql -a $2 -c "drop table alembic_version"
|
||||
heroku run -a $2 "python ${APPDIR:-.}/manage.py db init && python ${APPDIR:-.}/manage.py db migrate && python ${APPDIR:-.}/manage.py db upgrade"
|
||||
echo "Upgrade complete"
|
||||
|
||||
elif [ "$1" = "local" ]; then
|
||||
echo "Resetting local SQLite DB (dev.db)"
|
||||
rm -rf "${APPDIR:-.}/dev.db"
|
||||
python "${APPDIR:-.}/manage.py" db migrate
|
||||
elif [ "$1" = "sqlite" ]; then
|
||||
echo "Migrating local SQLite DB (dev.db)"
|
||||
python "${APPDIR:-.}/manage.py" db stamp --purge 7c3929047190
|
||||
python "${APPDIR:-.}/manage.py" db upgrade
|
||||
echo "Upgrade complete"
|
||||
|
||||
elif [ "$1" = "xsqlitex" ]; then
|
||||
echo "Wiping and resetting local SQLite DB (dev.db -> /tmp/dribdat-dev.db)"
|
||||
mv "${APPDIR:-.}/dev.db" "/tmp/dribdat-dev.db"
|
||||
rm -f "${APPDIR:-.}/dev.db"
|
||||
python "${APPDIR:-.}/manage.py" db upgrade
|
||||
echo "Upgrade complete"
|
||||
|
||||
else
|
||||
echo "Use this script with the following arguments to refresh the DB schema:"
|
||||
echo "Use this script with one of the following arguments to refresh your database:"
|
||||
echo " psql - in production (such as your server ssh console)"
|
||||
echo " heroku - to modify a locally configured remote app"
|
||||
echo " local - wipe and reset your development SQLite file (dev.db)"
|
||||
echo " sqlite - force migrate your development SQLite file (dev.db)"
|
||||
echo " xsqlitex - wipe and reset your development SQLite file (dev.db)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
if [ "$FORCE_MIGRATE" ]; then
|
||||
# Forced upgrade
|
||||
"${APPDIR:-.}/force-migrate.sh" psql
|
||||
echo "Warning! Your database may be out of sync due to a forced upgrade."
|
||||
|
||||
else
|
||||
# Standard upgrade
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue