Ticket #291 (closed defect: invalid)
Cannot alter mysql table
|Reported by:||shemigon@…||Owned by:||andrew|
I tried to add ForeignKey? to an existing table. In fact it needs to create integer field. After ./manage.py migrate was run I saw the following backtrace:
Running migrations for user: - Migrating forwards to 0002_add_plan. > user: 0002_add_plan Traceback (most recent call last): File "contrib/south/migration.py", line 330, in run_migrations db.execute_deferred_sql() File "contrib/south/db/generic.py", line 120, in execute_deferred_sql self.execute(sql) File "contrib/south/db/generic.py", line 86, in execute cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", line 84, in execute return self.cursor.execute(query, args) File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in execute self.errorhandler(self, exc, value) File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (1005, "Can't create table 'admin.#sql-591_b5' (errno: 150)") ! 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: = ALTER TABLE `accounts` DROP COLUMN `plan_id` CASCADE;  ! The South developers regret this has happened, and would ! like to gently persuade you to consider a slightly ! easier-to-deal-with DBMS.
As result necessary column has been created.
Mysql version is mysql Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (x86_64) using EditLine? wrapper