sobota 5. septembra 2009

How to reset Django Evolution of the project

Let's imagine the situation:

You have got into deadlock in Django Evolution and you cannot evolve forward.

You don't need the history of your evolutions (e.g. you use Subversion or other version control system, or you don't need history at all).

This was my case, I added some attributes to model, then installed Django Evolution, added 'django_evolution' to INSTALLED_APPS of my project, and ran 'python syncdb'. Problem was, that I did changes to model before those syncdb, and the problem appeared, when trying to remove that newly added attributes: Error applying evolution: column "title_before" of relation "core_person" does not exist.

Problem was, that Django Evolution thought, that those attributes existed, but they were not created in the database.

Maybe there is smarter solution, but this worked:

  1. Rollback your changes to model manually (e.g. comment newly added lines - attributes).

  2. Issue these commands in your project's directory:

    python reset django_evolution

    python syncdb

  3. Now you can do the changes again (or do other changes) and evolve issuing this command in your project's directory:

    python evolve --hint --sql
    python evolve --hint --execute

Update: other case, where this procedure is useful, is manual modification of database, not via Django Evolution. I was forced to do it also in this case.

Žiadne komentáre:

Zverejnenie komentára

Archív blogu