[Django]-New Django app initial DB migrations of an existing database

3👍

You want makemigrations to create the migrations. The migrate command applies migrations, it does not create them.

You can use the --fake-initial option so that Django does not try to create the tables that already exist. Note that --fake and --fake-initial are two different commands.

When you run migrate, the django_migrations table is updated to store the currently applied migrations. The migration files themselves are not changed. The --fake command updates the django_migrations table without running the migration. That means that if you use it incorrectly your database and django_migrations table can get out of sync, which can be difficult to fix.

Leave a comment