django migrate fake zero

  1. Open a terminal and navigate to the root directory of your Django project.

  2. Run the following command to create initial database migrations without actually applying them:

python manage.py migrate --fake-initial
  1. If you have already applied some migrations and want to mark them as already applied without actually running them, use the following command:
python manage.py migrate --fake
  1. If you want to set the database state to the initial state defined by the migrations, use the following command:
python manage.py migrate <app_name> zero

Replace <app_name> with the actual name of the app for which you want to reset migrations.

  1. Confirm the migration reset by answering 'yes' when prompted.

  2. The database will now be rolled back to the initial state specified in the migrations for the specified app.

  3. Optionally, you can run the following command to create and apply the initial migrations again:

python manage.py migrate