【发布时间】:2013-09-24 08:43:36
【问题描述】:
尝试使用 Yii 迁移删除一个表并创建 2 个。 这是代码:
<?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 命令尚未执行。表未删除,未创建其他表。数据库没有变化。找不到原因
【问题讨论】:
标签: php database web yii database-migration