Repository navigation
Replies: 1 comment 1 reply
|
Hi, Good question. That's not currently supported out of the box, as remake migration re-generate your DDL migration from scratch and delete all the migration files, without any special treatment for files for data migrations. Last time I checked, this was the same with the built-in Your best bet at the moment is probably to hook into I usually steer away from filling my DB with initial data, and use something like factory-boy to add whatever my test need. I also use a similar mechanism to seed a test database for deployment previews environments. I can see how it may be useful for some config-style tables holding near-static data which is used by most of the app, recreating and deleting them in every test is wasteful. It's just a problem I don't really have, perhaps due to the characteristics of the system I'm working on... Anyway, it's a bit of a long winded way of saying that this is currently not solved, but I'm open to a solution, as long as it's not too complicated to maintain. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
We are considering adopting remake-mirations for our projects, but it seems there is a blocker for us.
I'd like to ask how you deal with data migration to populate initial data in the context of unittests.
As explained from the django documentation,
https://docs.djangoproject.com/en/6.0/howto/initial-data/#provide-initial-data-with-migrations,
It is a known pattern to populate initial data with migrations.
It provides few guarantees
Now, If we optin for remake-migrations, we are going to loose our data migrations, as advertised, from the history. It is safe to do so for all envs, such dev/staging/production which already have the data, but it will defeat unittest data provisioining that is replaying the migration history every time we recreate the db (observed with pytest-django).
What's the recommended pattern to deal with initial data loading for unittests from existing migration history and use remake-migrations together ?
All reactions