0

I'm using a 3rd party dependency modeltranslation-lokalise which requires me to run python manage.py makemigration. This will generate a migration file that sits within the package directory once generated, and therefore are not source controlled.

For all other migration files I'm keeping them in source control and would like to do the same for these, as it will allow us to track changes to the database in the environments we use, ensuring they can be easily replicated and that operations are not duplicated on the same database (e.g. by having the same operation exist in differently-named migrations).

My question: How are these 3rd party migrations meant to be handled when building and deploying to production (e.g. via a Dockerfile in a build pipeline?

My guess would be to find a way to reliably extract the migration files from the package and add it to source control.

The alternative would be: run makemigrations within the Dockerfile that builds the deployed image, however that could result in the same migration being run twice on the database should the name of that migration change (e.g. if there's a timestamp in the name). So I'm thinking best to avoid that.

Note: this question is similar but it considers the use of the third part optional and doesn't seem to consider the above alternatives.

Jad S
  • 2,705
  • 6
  • 29
  • 49

1 Answers1

0

I solve this using the answer of this question:

Django migration file in an other app?

By using the MIGRATIONS_MODULE settings, I was able to point django to create the migrations in my source directory, and thereby commit them to source control.

Jad S
  • 2,705
  • 6
  • 29
  • 49