Created
November 9, 2023 20:51
-
-
Save TobeTek/ede692abbe13034ab2be7763583f4e13 to your computer and use it in GitHub Desktop.
Delete all migrations in a Django project
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/bash | |
# Written by ChatGPT with some human help 🙂 | |
# Loop through all apps in your project | |
for app in $(python manage.py showmigrations -l | grep -v '^\[ \]'); do | |
echo "Deleting migration files for $app..." | |
# Delete all migration files except __init__.py | |
find "$app/migrations" -name '00*.py' -not -name '__init__.py' -exec rm {} \; | |
echo "Migrations deleted for $app." | |
done | |
echo "All migration files deleted." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment