Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine migration. Add column after other one

$table = $schema->getTable('agent_documents');
$table->addColumn('name_r', 'string');

How to add this field not as last one, but after another one?

like image 424
Akhmed Avatar asked Jan 19 '16 09:01

Akhmed


1 Answers

Doctrine2 does not support adding column in other places than at the end. If you use ORM you shouldn't care about columns order. Nevertheless you could try to run instead SQL query (example for MySQL) like this:

$this->addSql('ALTER TABLE agent_documents ADD name_r VARCHAR(255) NOT NULL AFTER desired_column_name');
like image 157
Jakub Avatar answered Oct 21 '22 17:10

Jakub