Hey !
I was wondering if anyone has a setup, reusable app, sample code, or more generally inputs/ideas about test-running migrations on a copy of the production db ?
The goal is to reduce the risk of failure in data-migrations, as it happens that migrations run fine in dev/tests, but then fail on prod due to the data (integrity errors, etc.).
I was thinking of something like manage.py migrate --test-first
that would:
-
- create a test database (similarly to how the test framework creates a test database) using the prod database as a template
-
- run the migrations on the copy
- 3a. if it succeeds, run the migrations on prod db
- 3b. if it fails, don’t run the migrations
-
- delete the copy
Obviously that’s only suitable for small DBs, and for relatively simple projects, but would be quite practical.
Or otherwise how do you guys deal with potential migrations failures on prod ?
Cheers !!
Olivier