Last active
October 20, 2016 08:39
-
-
Save simion/eca0426de2bec242135c72e0ee274dd4 to your computer and use it in GitHub Desktop.
Reset Django migrations (delete everything and create initial migrations)
This file contains 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
#!/bin/sh | |
# this step is made only once by a single developer | |
# changes made by this script must be committed and pushed | |
if [[ `git status --porcelain` ]]; then | |
# working copy is not clean | |
echo "please commit or stash your changes" | |
exit | |
fi | |
# delete migrations | |
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete | |
find . -path "*/migrations/*.pyc" -delete | |
./manage.py makemigrations | |
git status | |
echo "Migrations deleted and initial migrations created. Please commit the changes" | |
# git add . | |
# git commit -m "reset migrations" | |
# git push |
This file contains 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
#!/bin/sh | |
# every developer should merge the previous changes and run: | |
mysql -u<db_user> -p <db_pass> <db_name> -e 'DELETE FROM `django_migrations` where `id` > 0;' | |
# and | |
./manage.py migrate --fake | |
# done | |
# you should do this also on production server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment