Is this really the way people migrate of test fixtures?

6 views
Skip to first unread message

Mike Lin

unread,
Dec 15, 2009, 4:00:29 PM12/15/09
to South Users
Hi, I'm new to south. It's great so far except I'm finding migration
of test fixtures a bit sticky.

I was really hoping to be able to automate this, but based on this
page:
http://ericholscher.com/blog/2009/jun/11/migrating-test-fixtures-using-south/

these are the steps that are needed:

1) after creating the migration, start from a fresh db, run syncdb and
migrate
2) run python manage.py migrate [the previous migration, the migration
the test data is at]
3) revert models.py to before changes
4) run python manage.py loaddata test_fixture.json
5) migrate
6) dumpdata. repeat 5-7 as needed.
7) revert models.py to current

Can I confirm that this is the way people do things? I'm hoping not
because it seems kind of painful. I'm pretty sure I'm not going to be
able to automate revert models.py part.

I wonder if a way around this is to keep fixtures as a direct db dump
or something to avoid using loaddata.

Thanks!

Andrew Godwin

unread,
Dec 19, 2009, 1:26:58 PM12/19/09
to south...@googlegroups.com
Working on automating this as a feature is on my todo list; it _is_ currently
a bit lengthly and verbose. However, I have to complete the startmigration
rewrite first, so it'll be a while before it makes it into trunk.

But, currently, this is the way you have to change fixtures. As an alternative,
you can either write a script to automate dumping out the data, or write a
migration that loads the fixture in a certainl place in the migration history,
so it's automatically loaded and upgraded on every new install.

Andrew

> --
>
> You received this message because you are subscribed to the Google Groups
> "South Users" group. To post to this group, send email to
> south...@googlegroups.com. To unsubscribe from this group, send email
> to south-users...@googlegroups.com. For more options, visit this
> group at http://groups.google.com/group/south-users?hl=en.
>

Carl Meyer

unread,
Dec 19, 2009, 7:16:25 PM12/19/09
to south...@googlegroups.com
On Tuesday 15 December 2009 21:00:29 Mike Lin wrote:
> 1) after creating the migration, start from a fresh db, run syncdb and
> migrate
> 2) run python manage.py migrate [the previous migration, the migration
> the test data is at]
> 3) revert models.py to before changes
> 4) run python manage.py loaddata test_fixture.json
> 5) migrate
> 6) dumpdata. repeat 5-7 as needed.
> 7) revert models.py to current

This is a lot less painful if you have the foresight to start with step
4 on a clean db immediately _before_ making the change to models.py in
the first place. Or if I've just made the models.py changes but haven't
committed yet (since I prefer to commit the migration along with the
models change), I use "hg shelve" to temporarily shelve the changes. In
any case, load the fixture before creating the migration, dump it
immediately after running it, and all is well.

Not that I won't be happy to see this workflow improved :-)

Carl

Mike Lin

unread,
Dec 28, 2009, 1:07:14 PM12/28/09
to South Users
Ok, thanks for the replies!

Unfortunately on svn Carl, so no shelve for this project, but as you
say a little foresight wouldn't hurt.

and I'll see if I can make this automatic loading and dumping work,
Andrew.

Mike Lin

Reply all
Reply to author
Forward
0 new messages