Modify

Ticket #291 (closed defect: invalid)

Opened 4 years ago

Last modified 3 years ago

Cannot alter mysql table

Reported by: shemigon@… Owned by: andrew
Priority: major Milestone:
Component: databaseapi Version: 0.6.2
Keywords: mysql field Cc:

Description

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

Attachments

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to assigned

Error 150 means that there's a ForeignKey? integrity error; does the other end of your ForeignKey? exist when this migration is being run?

comment:2 Changed 4 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to invalid

No response; closing.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.