Last active
September 29, 2017 04:34
-
-
Save paulwinex/65601bb424d8402addb2a26c17782fae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Backup database" | |
./manage.py dbt -qs | |
echo "Remove database" | |
# IF SQLITE | |
#rm ./db.sqlite3 | |
# IF POSTGRES | |
psql -U paul dbmane -t -c "select 'drop table \"' || tablename || '\" cascade;' from pg_tables where schemaname = 'public'" | psql -U paul dbmane | |
echo "Remove migrations" | |
rm -fR ./*/migrations | |
echo "Migrate..." | |
./manage.py makemigrations | |
./manage.py migrate | |
#rm ./db.sqlite3 | |
#chmod -R 777 ./db.sqlite3 | |
export DJANGO_SETTINGS_MODULE="main.settings" | |
echo "Restore database" | |
./manage.py dbt -qr -y | |
#python ./init_tst.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment