Commiting Django migration files to version control.

This is more of a question than asking for some technical help, but after researching for some posts in SO, people usually do makemigrations in development environment, commit the migration files to production and then migrate to apply the migrations to the database.

My question is, doesn’t that increase the repo size. With each version of the product, you might have a lot of migration files and that could (?) potentially bloat the repo.

1 Like

Two quick thoughts on this:

  • You only need to keep the migration files if you’re ever in a situation where you need to upgrade a system and need to keep the existing data. If you’re always deploying new instances and creating new databases, they’re not necessary.

  • The migration files are tiny compared to everything else you probably have in the repo. It’s not worth worrying about.

1 Like

In addition to Ken’s great points, if you do find an app has too many migrations, Django does support squashing migrations. You can read more on the squashmigrations command here.

Awesome ! Django has you covered all the way.