forcefully applying evolutions

2 views
Skip to first unread message

Ryszard Szopa

unread,
Apr 25, 2009, 1:14:21 PM4/25/09
to Django Evolution
Hi,

I have the following situation:

I started using django_evolution in an existing project, with an
existing app. On my computer, everything went fine: my models evolved,
I saved the evolutions under project/app/evolutions, and sent this to
the main repo. Then a colleague of mine pulled my changes and run
syncdb. When she tried to run manage.py evolve, however, django_evolve
wouldn't do anything, saying there are no evolutions to apply.

If I understand correctly, django_evolution took a snapshot of my
models (the baseline) at the time syncdb was done. The models aren't
changing, so that is understandable. I hoped, however, that I would be
able to use the evolutions I saved. This is not happening.

1) Is it possible to appy some evolution forcefully, even if
django_evolution thinks it is unnecessarry?

2) What is the right way of integrating django_evolution into an
existing project?

Cheers,

-- Ryszard

Russell Keith-Magee

unread,
Apr 26, 2009, 8:28:41 PM4/26/09
to django-e...@googlegroups.com

This is a slight complication of the evolution process. The problem is
caused by the "pulled my changes" step. In most cases, this just means
pulling whatever model changes and evolutions are new to your project;
however, in this case, the changes also include the adding of
Evolution itself to the project.

When the Evolution app is synchronized for the first time, it assumes
that any evolutions it finds have already been applied. This is to
allow for the most common use case - a completely new developer
downloading the code for your project that has a long history of
evolutions. This completely new user doesn't require the application
of any evolutions, since they are synchronizing clean model
definitions.

In your case, you have added evolution to your INSTALLED_APPS, _and_
added evolution definitions. When your friend pulls the changes,
Evolution synchronizes, and thinks that the "new" evolutions must have
already been applied. This is a problem in your case, since your
friend needs to run those evolutions.

The workflow workaround here is to ensure that when you add
django-evolution to your INSTALLED_APPS, you (and anyone else working
on your project) run syncdb _before_ you add any evolutions. This
allows Evolution to set up its tables with an empty pre-existing
evolution list.

Another way to work around this is to temporarily rename the
evolutions directory so that Evolution can't find those evolutions.
Once you have synchronized the evolution applicaiton, you can restore
the evolution directory. If you have already run syncdb, you may need
to drop the two tables created by evolution first. :-)

There is a long standing ticket to add a 'nudge' command that can
correct the model signatures - either to force a "no, there is no
evolution required", or to back out specific evolutions from the
stored history. One of these days, I may get some spare time to
implement this. If you're feeling particularly enthusiastic, it
shouldn't be too hard to implement this feature... patches welcome :-)

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages