Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#15926 closed New feature (fixed)

Option to not load initial fixtures during syncdb

Reported by: msiedlarek Owned by: msiedlarek
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: management syncdb options fixtures
Cc: msiedlarek, albrecht.andi@…, Jonathan Paugh Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

There are some situation in which you may want to prevent automatic loading of initial fixtures by syncdb management command. One example is when you want to create a database schema and fill it with data from the other database. If there were initial fixtures loaded in both databases there probably would be some primary key conflicts raised.

There is a stealth option for that, called load_initial_data, and used by testing setup, by I believe it's not fair to take away from user such a useful one.

Attachments (5)

ticket15926.patch (1.3 KB ) - added by msiedlarek 14 years ago.
Patch
ticket15926-with-flush.patch (2.8 KB ) - added by Jonathan Paugh 13 years ago.
Reincarnation of patch supporting the flush command as well
ticket15926-doc.patch (943 bytes ) - added by Jonathan Paugh 13 years ago.
Documentation for the (with-flush) patch
15926.patch (3.4 KB ) - added by vlinhart 13 years ago.
15926_test.patch (1.8 KB ) - added by vlinhart 13 years ago.

Download all attachments as: .zip

Change History (20)

by msiedlarek, 14 years ago

Attachment: ticket15926.patch added

Patch

comment:1 by msiedlarek, 14 years ago

Has patch: set

comment:2 by Aymeric Augustin, 14 years ago

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedDesign decision needed

Why not, but it sounds like you're misusing the initial_data fixtures.

In my understanding, they exist for data that will always be in your database and will not change. For example, you have some fixed categories used by M2M fields in other models, so you create a model for them and hardcode the list in a fixture.

comment:3 by msiedlarek, 14 years ago

I see your point, but as I said -- when you're using django-admin fixtures and syncdb everything should be ok, but when using some Django-independent database management utilities existence of initial data in freshly created database schema can cost you some trouble. In fact -- I'm facing this problem right now. Besides -- this is nice, simple feature which doesn't complicate anything that much.

comment:4 by Aymeric Augustin, 14 years ago

#15985 was a duplicate.

comment:5 by Andi Albrecht, 13 years ago

Cc: albrecht.andi@… added
UI/UX: unset

comment:6 by Aymeric Augustin, 13 years ago

Easy pickings: set
Triage Stage: Design decision neededAccepted

comment:7 by Aymeric Augustin, 13 years ago

#9549 is related.

comment:8 by Jonathan Paugh, 13 years ago

Patch needs improvement: set

What about the flush command? This change should be included there, too. I'm marking the patch as 'needs improvement.' By the way, I think this feature can be very useful, for development anyway. Whenever I change my models and need to resync, I often want to quickly verify the model without having to update my initial data---sometimes this is necessary anyway, but not always.

by Jonathan Paugh, 13 years ago

Reincarnation of patch supporting the flush command as well

by Jonathan Paugh, 13 years ago

Attachment: ticket15926-doc.patch added

Documentation for the (with-flush) patch

comment:9 by Jonathan Paugh, 13 years ago

Cc: Jonathan Paugh added
Needs documentation: unset
Patch needs improvement: unset

I think with the new patch and the documentation patch, this is ready for review by a core dev. Sorry for stealing your thunder, msiedlarek.

comment:10 by Jonathan Paugh, 13 years ago

Version: 1.3SVN

I made my patches against the SVN (git) tip, so I changed the version. I'm guessing that's the protocol.

comment:11 by Aymeric Augustin, 13 years ago

Patch needs improvement: set

Could you:

  • consolidate all the changes in a single diff file?
  • ensure you're indenting consistently with the surrounding code?

Also, this still needs tests.

comment:12 by vlinhart, 13 years ago

I've consolidated the three pathes into one and are now up-todate with the current head. There is another patch which contains tests.

by vlinhart, 13 years ago

Attachment: 15926.patch added

by vlinhart, 13 years ago

Attachment: 15926_test.patch added

comment:13 by Honza Kral <honza.kral@…>, 13 years ago

Resolution: fixed
Status: newclosed

In [fedac99c859c626544d38fc0ea07207ef3fd101a]:

Fixed #15926 -- Added option --no-initial-data to syncdb and flush.

Thanks msiedlarek, jpaugh64 and vlinhart!

comment:14 by Claude Paroz <claude@…>, 13 years ago

In [f0664dc8ae541b21e3cf421725e7933a9b3a799e]:

Made TestNoInitialDataLoading pass with MySQL (Refs #15926)

comment:15 by Claude Paroz <claude@…>, 13 years ago

In [2c57809a560cb67c79b9e8a77cc713e8a2424c8e]:

Prevented TestNoInitialDataLoading to pollute other tests (Refs #15926)

Tests were still failing with MySQL. It seems a rollback is solving
the issue.

Note: See TracTickets for help on using tickets.
Back to Top