delete all migrations django
To delete all migrations in Django, you can follow these steps:
- Open your command line or terminal.
- Navigate to your Django project's root directory.
Run the following command:
python manage.py migrate app_name zero
Replace
app_name
with the name of the app for which you want to delete the migrations. If you want to delete migrations for all apps, omit theapp_name
parameter.
This command sets the specified app's migration history to the initial state (zero).
Delete the migration files manually.
Navigate to the
migrations
directory inside each app for which you want to delete the migrations.Delete all the migration files in that directory except for the
__init__.py
file.Repeat steps 3 and 4 for each app that has migrations you want to delete.
By following these steps, you will effectively delete all the migrations for the specified app or apps in Django. Remember to be cautious when performing this operation, as it will remove the migration history and can potentially lead to data loss or inconsistencies in your database. Make sure to have a backup of your data before proceeding.