Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 migration - add column after other one

Tags:

yii2

I want to add a new column through migration in Yii2, using this code:

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

public function down()
{
    $this->dropColumn('news', 'priority');
}

And it works but I want it to be second column, after name.

It is possible?

like image 474
emptimd Avatar asked Oct 14 '25 23:10

emptimd


1 Answers

OK, can you try this:

$this->addColumn('news', 'priority', 'integer AFTER `name`');
like image 95
XTL Avatar answered Oct 18 '25 03:10

XTL