2016-08-26 7 views
2

VPSでDjangoとMySQLを使用しています。 python manage.py migrateを実行すると、次のエラーが発生します。しかし、私の開発サーバーでは、私はsqliteを使用し、移行は正常に動作します。重複する列名 'model_id' djangoマイグレーション時にエラーが発生しました

Running migrations: 
    Rendering model states... DONE 
    Applying bloupergroups.0002_auto_20160826_1138...Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line 
    utility.execute() 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute 
    output = self.handle(*args, **options) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle 
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate 
    self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards 
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 198, in apply_migration 
    state = migration.apply(state, schema_editor) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 123, in apply 
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards 
    field, 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 50, in add_field 
    super(DatabaseSchemaEditor, self).add_field(model, field) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 396, in add_field 
    self.execute(sql, params) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 110, in execute 
    cursor.execute(sql, params) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute 
    return super(CursorDebugWrapper, self).execute(sql, params) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 112, in execute 
    return self.cursor.execute(query, args) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 226, in execute 
    self.errorhandler(self, exc, value) 
    File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler 
    raise errorvalue 
django.db.utils.OperationalError: (1060, "Duplicate column name 'blouper_id'") 

ここでの問題はわかりません。

+1

お使いのモデルを表示してください。 – elethan

+0

すべてのモデル?または特定のもの? –

答えて

1

Djangoはすでに適用されている移行を適用しようとしている可能性があります。

は、ドキュメントからpython manage.py migrate --fake-initial

を実行してみましょう:すべてのモデルの名前を持つすべてのデータベーステーブルは、すべてのたcreateModel操作によって作成された場合

--fake-初期 は、Djangoがアプリケーションの最初の移行をスキップすることができますその移行は既に存在しています。このオプションは、移行を事前に使用していたデータベースに対して最初に移行を実行するときに使用するためのものです。ただし、このオプションでは、一致するテーブル名と一致するデータベーススキーマはないので、既存のスキーマが初期移行で記録されているスキーマと一致していると確信している場合にのみ安全に使用できます。

+0

' 実行移行: レンダリングモデルの状態は... bloupergroups.0002_auto_20160826_1138適用 をDONE ...適用 を偽造feedback.0001_initial ... OK 'これは魅力のように働いた出力 –

+0

ました。どうもありがとう!!! –

関連する問題