这是我的表的结构:
CREATE TABLE `company_info` (
`id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_polish_ci DEFAULT NULL,
`description` longtext COLLATE utf8_polish_ci,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_info` date DEFAULT NULL,
`company_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Index_1` (`id`),
KEY `FK_Reference_4` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci
我需要更改它,在 Yii 1.x 中使用 CDbMigration。目前, key FK_Reference_4
( ) 是tablecompany_id
的外键。我试着:id
company
- 删除旧的外键,
- 将新表添加到另一个表 (
users
)。
当我尝试执行迁移时,使用yiic migration
,它在命令上失败:
$this->dropForeignKey('FK_Reference_4','company_info');
出现以下错误:
Exception: CDbCommand failed to execute the SQL
statement: SQLSTATE[HY000]: General error: 1025 Error on rename of '.\focuserv\
company_info' to '.\focuserv\#sql2-1b0-18' (errno: 152). The SQL statement execu
ted was: ALTER TABLE `company_info` DROP FOREIGN KEY `FK_Reference_4` (E:\IDEs\w
amp\www\focuserv\focuserv\framework\db\CDbCommand.php:358)
dropForeignKey
失败也是如此。我应该如何修复或解决此问题?