我需要帮助调试迁移。
我尝试逐步执行每个查询,以找到django迁移停止的位置。
此查询失败:
mysql> ALTER TABLE `elezioniAgendaCore_comments` ADD CONSTRAINT `elezioniAgendaCore_comments_uid_id_670175fa07fa7b47_fk_user_uid` FOREIGN KEY (`uid_id`) REFERENCES `user` (`uid`);
错误:
ERROR 1005 (HY000): Can't create table 'activedoc.#sql-3f7_2b' (errno: 150)
我有两张桌子。
TABLE用户:
mysql> show columns from user;
+-------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+----------------+
| uid | bigint(20) | NO | PRI | NULL | auto_increment |
| name | varchar(50) | YES | MUL | NULL | |
| surname | varchar(50) | YES | MUL | NULL | |
| email | varchar(100) | YES | MUL | NULL | |
+-------------------+--------------+------+-----+---------+----------------+
表elezioniAgenda评论:
mysql> show columns from elezioniAgendaCore_comments;
+------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| signature | varchar(255) | NO | | NULL | |
| message | longtext | NO | | NULL | |
| created | datetime | NO | | NULL | |
| published | tinyint(1) | NO | | NULL | |
| adempimento_id | int(11) | NO | MUL | NULL | |
| parentComment_id | int(11) | YES | MUL | NULL | |
| uid_id | bigint(20) | NO | | NULL | |
+------------------+--------------+------+-----+---------+----------------+
答案 0 :(得分:1)
我发现一个表是使用MyISAM引擎创建的:
SHOW CREATE TABLE user;
[...]
) ENGINE=MyISAM AUTO_INCREMENT=307 DEFAULT CHARSET=latin1 |
另一张表:
mysql> SHOW CREATE TABLE elezioniAgendaCore_comments;
[...]
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
然后我迁移到InnoDB两个表。这次没有错误。