Opened 2 years ago

Closed 2 years ago

#33427 closed New feature (wontfix)

Add new flag in loaddata command that loads fixture without overriding existing objects with same primary key

Reported by: Mohit Solanki Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: loaddata, fixture, command
Cc: me@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mohit Solanki)

Installing fixtures with django's loaddata command overrides objects with the same primary key.
While this is not a problem if you are installing the fixtures against a fresh DB with no data but in case you have
existing data then loading the fixture can be problematic as all the existing rows with the same primary key will be updated
with the new data from the fixture(s)
It would be a good idea to have an additional flag like for e.g --insert-only or something that tells django not to override existing objects with the same primary key.

Note: I created this package to solve this issue but I think It would be a good idea to add this functionality to loaddata itself

Change History (4)

comment:1 by Mohit Solanki, 2 years ago

Description: modified (diff)

comment:2 by Adam Johnson, 2 years ago

Thanks for submitting the ticket Mohit. I'll let someone else (probably a fellow) comment if it's worth accepting.

comment:3 by Carlton Gibson, 2 years ago

Hi Mohit.

I'm going to say wontfix here initially: I'm not sure there's much benefit in complicating loaddata; the thought is to create your own command if you need this, which is just what you've done — nice working sharing that.

It may be that a post to the DevelopersMailingList or Forum would show more demand in which case we could re-open…

comment:4 by Carlton Gibson, 2 years ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top