#23077 closed Bug (invalid)
Django 1.7 rc1 flush command loads initial data regardless of the migrations
Reported by: | linovia | Owned by: | Andrew Godwin |
---|---|---|---|
Component: | Migrations | Version: | 1.7-rc-1 |
Severity: | Release blocker | Keywords: | |
Cc: | xordoquy@…, Tim Graham | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This is following ticket #23031
We have an issue with test runner that crashes on application that has both initial_data and migrations.
The reason is the database is flushed before the migration however, flush command will try to load initial_data anyway. This will crash the test runner.
Following the documentation, initial_data is deprecated, not yet forbidden at all.
Attachments (2)
Change History (14)
comment:1 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 10 years ago
Attachment: | 23077.diff added |
---|
comment:3 by , 10 years ago
Doesn't the patch prevents any load data for migrated application ?
I mean, it looks like Django wouldn't be able to use loaddata for any migrated application which I is not something we want, do we ?
All I can see in the release notes is that initial_data shouldn't be possible for migrated apps.
comment:4 by , 10 years ago
I agree with @linovia. I looked at it briefly and I think we could probably pass the test_database
flag from migrate to loaddata
(via flush
) and check that before skipping initial data for apps with migrations.
comment:5 by , 10 years ago
ouch i've just seen some easier way maybe.
check that patch...
https://code.djangoproject.com/attachment/ticket/23077/new-23077.diff
If totally overseen the load_initial_data flag
Edit: now it won't load initial_data on migrate (which is the behavior told in the docs)
by , 10 years ago
Attachment: | new-23077.diff added |
---|
comment:6 by , 10 years ago
if this is the desired behavior i would write a test, that tests the test runner.
comment:8 by , 10 years ago
It may be easier/simpler to keep the test localized to the migrate command instead of testing the behavior indirectly through the test runner.
comment:9 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
That patch will disable initial data loading for _all_ apps - it should be disabled for just the ones with migrations. I'll modify flush to only load apps mentioned in loader.unmigrated_apps.
comment:10 by , 10 years ago
After actually looking into this, there is no way to prevent people mentioning models that are migrated in fixtures in unmigrated apps (Django doesn't segregate models during fixture loading), so I'm going to say this is still a documentation issue and that you should just delete the initial_data fixtures from your migrated apps.
Additionally, I'm going to start initial_data on the deprecation path, so if you run with pending deprecation warnings turned on you'll see errors (and you'll definitely see them in 1.8).
comment:11 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
That is somewhat funny.
I don't know if this is a good solution. But I wrote a patch for it. And attach it here.
Somehow migrated apps who has fixture were loaded, too.
I don't have any output yet since I didn't know if this is wished. Maybe a Note at the start of loaddata would be enough since its in the patchnotes anyway.
Oh and running against master works fine.