I accidentally executed:

 manage.py migrate forum --fake

Now I want to do actual migration. But when I run "manage.py migrate forum" I get message "nothing to migrate". When I run "manage.py migrate forum --all" I get:

  File "c:\\python26\\lib\\site-packages\\south-0.7.3-py2.6.egg\\south\\migration\\base.py", line 204, in _guess_migration
    raise exceptions.UnknownMigration(prefix, None)
south.exceptions.UnknownMigration

How to redo migration?

BTW: I'm trying to migrate from beta1 to beta3.

asked 22 Mar '11, 12:34

Shrike's gravatar image

Shrike
37691522
accept rate: 33%

edited 22 Mar '11, 18:50


All the migrations, that have previously been triggered are stored in the database in a table called south_migrationhistory.

The migrations that are saved inside this table are not going to be triggered anymore. So if you want to run them again, you have to delete their records from that table.

If you're using MySQL this can be done through PhpMyAdmin, if using PgSQL, through PgAdmin III. You can also do this through the Django Project management shell.

  1. python manage.py shell
  2. from south.models import MigrationHistory
  3. m = MigrationHistory.objects.get(migration="<migration_name>")
  4. m.delete()

If you're migrating between OSQA Fantasy Island Beta2 and Beta3 you'll probably have to take into consideration the migrations between 0043 and 0048.

link

answered 24 Mar '11, 07:44

Jordan's gravatar image

Jordan ♦♦
3.1k618
accept rate: 38%

Thank you very much. Could you tell me how can I find out which migrations in the table was created as "fake"?

(24 Mar '11, 07:51) Shrike

Probably I should clarify. I had beta 1 installed. Then moved to beta 3 and executed "migrate --fake". That didn't change my DB but created some rows in south_migrarionhistory. Now I want to rollback to beta1. Now to find out for sure which rows in south_migrationhistory should I delete? You said "probably between 43-48", ok, but I'd like to have a generic method for rolling back.

(24 Mar '11, 16:46) Shrike
1

@Shrike, take a look at the folder forum/migrations. Based on the timestamps of the files, you can figure which migrations showed up only after the upgrade. Then just delete the corresponding records, either directly in the database, or using the method Jordan described.

(24 Mar '11, 16:50) Hernani Cerq... ♦♦

If you executed the migrations with a "--fake" parameter you'll just have to remove the items from the migration history table.

It's not a good idea to use the "backwards" methods of the migrations.

After that a simple update of the code to the revision of the Beta2 Release would be enough.

svn update -r 736 (736 is the revision # of Fantasy Island Beta 2)

(24 Mar '11, 16:58) Jordan ♦♦

Thanks! By comparing two distributives I've found all migrations and successfully delete them. BTW: they are 45-48

(24 Mar '11, 17:27) Shrike

when input

python manage.py shell from south.models import MigrationHistory m = MigrationHistory.objects.get(migration="<migration_name>") m.delete()

then

C:\Python26\Lib\site-packages\OSQA>python manage.py shell
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from south.models import MigrationHistory
>>> m = MigrationHistory.objects.get(migration="<migration_name>")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python26\lib\site-packages\django\db\models\manager.py", line 132, in
 get
    return self.get_query_set().get(*args, **kwargs)
  File "C:\Python26\lib\site-packages\django\db\models\query.py", line 347, in g
et
    % self.model._meta.object_name)
DoesNotExist: MigrationHistory matching query does not exist.
>>>

why???
link

answered 06 Apr, 23:32

ticktack's gravatar image

ticktack
226
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×37
×4

Asked: 22 Mar '11, 12:34

Seen: 1,191 times

Last updated: 06 Apr, 23:32

powered by OSQA