Last active
May 10, 2021 16:16
-
-
Save s4n7h0/e4b3b8e230bccc234f9a872fd36b5448 to your computer and use it in GitHub Desktop.
Bash script to clean up django migration
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
#!/bin/sh | |
# This script is for cleaning up django migration | |
echo "Starting to clean up..." | |
# when deleting old migration, ensure not to delete the files under /django/db/migrations/ | |
echo ">> Deleting old migrations" | |
find . -path "*/migrations/*.py" -not -path "*/venv/*" -not -name "__init__.py" -delete | |
find . -path "*/migrations/*.pyc" -not -path "*/venv/*" -delete | |
# Optional to delete if sqlite DB is used. If mysql, do the clean up manually | |
echo ">> Deleting sqlite (if exists) database" | |
find . -name "db.sqlite3" -delete | |
echo ">> Running manage.py makemigrations" | |
python manage.py makemigrations | |
echo ">> Running manage.py migrate" | |
python manage.py migrate | |
echo ">> Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment