尝试使用 Yii 迁移删除一个表并创建另一个表。这是代码:
<?php
class m130919_095159_create_offer_tables extends CDbMigration
{
public function up()
{
$this->getDbConnection()->createCommand()->dropTable('offer');
$this->createTable('settings', array(
'id' => 'pk',
'offer_id' => 'integer NOT NULL',
'system_id' => 'integer NULL',
'site_title' => 'varchar(255) NULL',
'index_number' => 'integer NULL',
'coupon_token' => 'varchar(255) NULL',
'facebook_app_id' => 'varchar(255) NULL',
'facebook_app_secret' => 'varchar(255) NULL',
));
$this->createTable('content', array(
'id' => 'pk',
'offer_id' => 'integer NOT NULL',
'created' => 'datetime NOT NULL',
'modified' => 'datetime NOT NULL',
'status' => 'integer NOT NULL',
'title_uz' => 'varchar(255) NULL',
'title_ru' => 'varchar(255) NULL',
'description_uz' => 'text NULL',
'description_ru' => 'text NULL',
));
}
public function down()
{
echo "m130919_095159_create_offer_tables does not support migration down.\n";
return false;
}
}
在我执行命令php yiic.php migrate
并得到答案后migrated up successfully
。问题是 sql 命令尚未执行。表未删除,未创建其他表。数据库没有变化。查不出原因