Skip to content

Instantly share code, notes, and snippets.

@s4n7h0
Last active May 10, 2021 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s4n7h0/e4b3b8e230bccc234f9a872fd36b5448 to your computer and use it in GitHub Desktop.
Save s4n7h0/e4b3b8e230bccc234f9a872fd36b5448 to your computer and use it in GitHub Desktop.
Bash script to clean up django migration
#!/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