dibs_ab dibs_ab - 1 year ago 173
PHP Question

addColumn yii migration position

I want to add a column at the seventh place in the table, I am using


adds the column at the end. Is there any way where I can mention the place to add column? Or any after column keyword to add my new column after, for exapmle, password column.
I have learnt aboout migration from Yii Doc

Answer Source

This should work!

$this->addColumn('table_name', 'column_name', 'type AFTER column6'); 


$this->addColumn('tbl_posts', 'email', 'VARCHAR(150) AFTER `name` ');
$this->addColumn('tbl_posts', 'phone', 'string AFTER `email` ');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download