Yii2迁移-在另一列之后添加列

Yii2迁移-在另一列之后添加列,yii2,Yii2,我想通过在Yii2中迁移添加一个新列,使用以下代码: public function up() { $this->addColumn('news', 'priority', $this->integer()); } public function down() { $this->dropColumn('news', 'priority'); } 它可以工作,但我希望它是第二列,在name之后 有可能吗?好的,你能试试这个吗: $this->addCol

我想通过在Yii2中迁移添加一个新列,使用以下代码:

public function up()
{
    $this->addColumn('news', 'priority', $this->integer());
}

public function down()
{
    $this->dropColumn('news', 'priority');
}
它可以工作,但我希望它是第二列,在name之后


有可能吗?

好的,你能试试这个吗:

$this->addColumn('news', 'priority', 'integer AFTER `name`');

自v2.0.8以来,您还可以执行以下操作:

$this->addColumn('news', 'priority', $this->integer()->after('name'));