Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

jplindstrom
  (email not shown publicly)

Journal of jplindstrom (594)

Monday January 21, 2008
07:03 AM

MySQL: error 150 on rename column

[ #35440 ]

Dear Google Search Result Page!

So this fails on an InnoDB table in MySQL 5.0:

ALTER TABLE `xxx_table`
    CHANGE COLUMN `importid` `import_id` int(11) NOT NULL;

with this luvely error message:

#   Failed test 'Migrating up to 29 '
#   at t/unit/db/migrations.t line 84.
ERROR : DBD::mysql::db do failed: Error on rename of
'./xxx_tmp_migration_test_1200915479/#sql-4dcf_348f2' to
'./xxx_tmp_migration_test_1200915479/xxx_table' (errno: 150)

Why is this?

At first I thought it was because importid is part of the composite PK (it's a link table), but that's not it.

It turns out that there is a FK constraint on importid to another table. Deleting the FK and reinstating it with the new column name solves the problem.

Thanks for the self explanatory error message MySQL, that was very helpful.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.