2011-03-10 4 views
0

J'ai une application existante nommée auth avec des modèles et des db synchronisés avec des tables. J'installe south dans les paramètres du projet, exécutez ./manage.py convert_to_south auth. Il a créé et appliqué avec succès une fausse migration. Puis j'ajoute un nouveau modèle dans cette application et exécute ./manage.py schemamigration auth --auto. Et quand je suis en train de migrer en terme ./manage.py migrate auto il me donne cette erreur énorme:Erreur de l'outil de migration de Django vers le sud avec l'application existante

+ Added model auth.RegisterTicket 
Created 0002_auto__add_registerticket.py. You can now apply this migration with: ./manage.py migrate auth 
nukl-MacBook:website nukl$ django migrate auth 
Running migrations for auth: 
- Migrating forwards to 0002_auto__add_registerticket. 
> auth:0002_auto__add_registerticket 
! Error found during real run of migration! Aborting. 

! Since you have a database that does not support running 
! schema-altering statements in transactions, we have had 
! to leave it in an interim state between migrations. 

! You *might* be able to recover with: = DROP TABLE `auth_registerticket` CASCADE; [] 

! The South developers regret this has happened, and would 
! like to gently persuade you to consider a slightly 
! easier-to-deal-with DBMS. 
! NOTE: The error which caused the migration to fail is further up. 
Traceback (most recent call last): 
    File "manage.py", line 11, in <module> 
    execute_manager(settings) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager 
    utility.execute() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute 
    output = self.handle(*args, **options) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/management/commands/migrate.py", line 105, in handle 
    ignore_ghosts = ignore_ghosts, 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/__init__.py", line 191, in migrate_app 
    success = migrator.migrate_many(target, workplan, database) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 221, in migrate_many 
    result = migrator.__class__.migrate_many(migrator, target, migrations, database) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 292, in migrate_many 
    result = self.migrate(migration, database) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 125, in migrate 
    result = self.run(migration) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 99, in run 
    return self.run_migration(migration) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 81, in run_migration 
    migration_function() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 57, in <lambda> 
    return (lambda: direction(orm)) 
    File "/migrations/0002_auto__add_registerticket.py", line 16, in forwards 
    ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/db/generic.py", line 226, in create_table 
    ', '.join([col for col in columns if col]), 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.3-py2.7.egg/south/db/generic.py", line 150, in execute 
    cursor.execute(sql, params) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", line 15, in execute 
    return self.cursor.execute(sql, params) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute 
    return self.cursor.execute(query, args) 
    File "build/bdist.macosx-10.6-intel/egg/MySQLdb/cursors.py", line 174, in execute 
    File "build/bdist.macosx-10.6-intel/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler 
_mysql_exceptions.OperationalError: (1050, "Table 'auth_registerticket' already exists") 

Toutes les idées?

+0

Les instructions sont ci-dessus. L'as tu essayé? – gladysbixly

+0

quelles instructions? comment supprimer la table créée? – nukl

Répondre

0

On dirait que la table auth_registerticket existe déjà. Avez-vous essayé de le supprimer et de réappliquer la migration?

2

J'ai eu une erreur similaire l'autre jour. C'est arrivé parce que j'utilisais MySQL et la partie forwards() de la migration ne s'exécute pas dans une transaction sur MySQL. Cela m'a causé un problème où je n'ai pas pu résoudre le problème en migrant vers le bas puis en remontant car la table south_migrationhistory n'a pas enregistré ma migration la plus récente. Pour résoudre ce problème, j'ai lancé la migration avec --fake afin de mettre à jour l'historique de la migration. Ensuite, j'ai dû essayer/à l'exception de tout ce qui concernait les index dans ma dernière migration et j'étais capable de revenir en arrière puis de reculer.

Questions connexes