You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I often want to test my changes against the latest production database and make sure the migrations are correct. I wrote a script that prints the two simple commands to get the latest database, and then asks if you'd like to restore it, make migrations, and migrate. It has been so helpful that I now use it on all my projects. I thought it might make a good addition to cookiecutter-django. If there is interest I could make any changes suggested here and add a pull request. Would it go in the root folder or bin?
#!/usr/bin/env bashprintf"\nTo get a new backup from Heroku:\nheroku pg:backups capture\nheroku pg:backups download\n\n"
dump_file=$(ls -1r latest.dump*| head -n1)
database=$(basename $(pwd))read -p "Restoring ${dump_file} to database ${database}. Continue? " -n 1 -r
echoif [[ !$REPLY=~ ^[Yy]$ ]]
then
[[ "$0"="$BASH_SOURCE" ]] &&exit 1 ||return 1 # handle exits from shell or function but don't exit interactive shellfi
dropdb ${database}&& \
createdb ${database}&& \
pg_restore --no-acl --no-owner -d ${database}${dump_file}&& \
./manage.py makemigrations && \
./manage.py migrate && \
printf"Success!\n"
The text was updated successfully, but these errors were encountered:
@jeffcjohnson , as for the script location, we keep other postgres service-related shell scripts in ./compose/postgres/ for now, and copy them to the image's /usr/local/bin/.
Hi, I often want to test my changes against the latest production database and make sure the migrations are correct. I wrote a script that prints the two simple commands to get the latest database, and then asks if you'd like to restore it, make migrations, and migrate. It has been so helpful that I now use it on all my projects. I thought it might make a good addition to cookiecutter-django. If there is interest I could make any changes suggested here and add a pull request. Would it go in the root folder or bin?
The text was updated successfully, but these errors were encountered: