【发布时间】:2018-06-15 02:33:35
【问题描述】:
- 在 Windows 上运行 XAMPP 机器,我尝试运行命令:
-
我在下面运行了迁移
使用 yii\db\Migration; // 类 m180614_020037_create_table_place_lang m180614_020037_create_table_place_lang 类扩展了迁移 { /** * {@inheritdoc} */ 公共函数 up() { $this->createTable('place_lang', [ 'id' => $this->primaryKey()->unsigned(), 'place_id' => $this->integer(11)->unsigned()->notNull(), 'locality' => $this->string(45)->notNull(), '国家' => $this->string(45)->notNull(), 'lang' => $this->string(2)->notNull() ]);
}$this->createIndex( 'idx_place_lang_id_place', 'place_lang', 'place_id' ); $this->addForeignKey( 'fk_place_lang_id_place', 'place_lang', 'place_id', 'place', 'id' ); } /** * {@inheritdoc} */ public function down() { $this->dropForeignKey('fk_place_lang_id_place', 'place_lang'); $this->dropIndex('idx_place_lang_id_place', 'place_lang'); $this->dropTable('place_lang'); return false; }数据库表已删除,但迁移失败,我无法继续迁移堆栈。
在堆栈下面看到另一个迁移:
<?php
use yii\db\Migration;
/**
* Class m180614_015652_create_table_place
*/
class m180614_015652_create_table_place extends Migration
{
/**
* {@inheritdoc}
*/
public function up()
{
$this->createTable('place', [
'id' => $this->primaryKey()->unsigned()->notNull(),
'place_id' => $this->string(45)->notNull(),
'lat' => $this->string(45)->notNull(),
'lng' => $this->string(45)->notNull(),
'country_code' => $this->string(2)->notNull(),
'is_country' => $this->tinyInteger(4)->notNull()
]);
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->dropTable('place');
return false;
}
}
这是 yii 2 在 Windows 和 XAMPP 上的限制,还是只是使用框架的新手错误?
【问题讨论】:
-
另外,当我运行 ./yii migrate/fresh 时,一切都按预期工作
-
you returned false 在 down() 中,因此迁移假定它已失败。删除
return false。