--(2141:Fri,17 Apr 15:$ )-- mysql -uroot -e 'drop database django_test;create database django_test;' && ./manage.py migrate Operations to perform: Synchronize unmigrated apps: messages, staticfiles Apply all migrations: admin, contenttypes, polls, sessions, auth Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying polls.0001_initial... OK Applying polls.0002_remove_choice_question...Traceback (most recent call last): File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 220, in execute self.errorhandler(self, exc, value) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorvalue File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 209, in execute r = self._query(query) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 371, in _query rowcount = self._do_query(q) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 335, in _do_query db.query(q) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) _mysql_exceptions.OperationalError: (1553, "Cannot drop index 'polls_choice_7aa0f6ee': needed in a foreign key constraint") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./manage.py", line 10, in execute_from_command_line(sys.argv) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 221, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/migrations/executor.py", line 110, in migrate self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/migrations/executor.py", line 147, in apply_migration state = migration.apply(state, schema_editor) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/migrations/migration.py", line 115, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 121, in database_forwards schema_editor.remove_field(from_model, from_model._meta.get_field(self.name)) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 441, in remove_field self.execute(sql) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 107, in execute cursor.execute(sql, params) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 220, in execute self.errorhandler(self, exc, value) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorvalue File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 209, in execute r = self._query(query) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 371, in _query rowcount = self._do_query(q) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 335, in _do_query db.query(q) File "/Users/laszlokarolyi/Work/django-test/virtualenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1553, "Cannot drop index 'polls_choice_7aa0f6ee': needed in a foreign key constraint")