так и есть:
Server version: 5.5.61-38.13 Percona Server (GPL), Release 38.13, Revision 812705b
mysql> CREATE TABLE
table1 (
->
id int(11) NOT NULL AUTO_INCREMENT,
-> PRIMARY KEY (
id)
-> ) ENGINE=InnoDB AUTO_INCREMENT=1238576152 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE TABLE
table2 (
->
id int(11) NOT NULL AUTO_INCREMENT,
->
external_id int(11) NOT NULL,
-> PRIMARY KEY (
id),
-> CONSTRAINT
FK_table2_123 FOREIGN KEY (
external_id) REFERENCES
table1 (
id)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO table1 (id) VALUES (123);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO table2 (id, external_id) VALUES (1, 123);
Query OK, 1 row affected (0.01 sec)
mysql> SET FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER TABLE table1 MODIFY id BIGINT NOT NULL AUTO_INCREMENT;
ERROR 1025 (HY000): Error on rename of './/#sql-1_15c' to './/table1' (errno: 150)
mysql> SHOW ENGINE INNODB STATUS;
------------------------
LATEST FOREIGN KEY ERROR
------------------------
200527 19:03:00 Error in foreign key constraint of table /table2:
there is no index in referenced table which would contain
the columns as the first columns, or the data types in the
referenced table do not match the ones in table. Constraint:
,
CONSTRAINT "FK_table2_123" FOREIGN KEY ("external_id") REFERENCES "table1" ("id")
The index in the foreign key in table is "FK_table2_123"
See
http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.htmlfor correct foreign key definition.
--------