我正在用Yii创建一个测试应用程序,并且已经创建了我的第一个迁移。
<?php
class m111128_223507_reverse_bed_patient extends CDbMigration
{
public function up()
{
$this->dropForeignKey('fk_bed_patient1', 'bed');
$this->dropColumn('bed', 'patient_id');
$this->addColumn('patient', 'bed_id', 'int(11)');
$this->addForeignKey('fk_patient_bed1', 'patient', 'bed_id', 'bed', 'id', 'NO ACTION', 'NO ACTION');
}
public function down()
{
echo "m111128_223507_reverse_bed_patient does not support migration down.'n";
return false;
}
}
出于某种原因,Yii认为我正在使用SQLite数据库,即使在我的应用程序main.php中,我有MySQL设置在其他任何地方都能正确工作,SQLite行被注释掉。
当我尝试第一次迁移时,我得到这个错误。
*应用m111128_223507_reverse_bed_patient从表床删除列patient_id…sqllite不支持删除DB列,导致数据库异常。
我在这里错过了什么?
可能您的yiic
工具正在使用console.php
配置文件(因为它在Yii中是默认的),请尝试查看protected/config/console.php
中的DB连接设置。