Created
April 20, 2020 14:35
-
-
Save russell310/22fa7f9329a458467d4bcd99e917c86c to your computer and use it in GitHub Desktop.
Sometime needs to delete all migration file in django here is how you will reset migrations file
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
| import os | |
| import glob | |
| dot_py = glob.glob('*/migrations/*.py', recursive=True) | |
| for filePath in dot_py: | |
| if not os.path.basename(filePath) == '__init__.py': | |
| try: | |
| os.remove(filePath) | |
| except OSError: | |
| print("Error while deleting file") | |
| dot_pyc = glob.glob('*/migrations/*.pyc', recursive=True) | |
| for filePath in dot_pyc: | |
| try: | |
| os.remove(filePath) | |
| except OSError: | |
| print("Error while deleting file") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment