Reputation: 77
I use DoctrineMigrationsBundle to add tables and columns in a database. And now my question is how to move an existing column to another position in the table or if it creates new immediately specify where it would be located was not on the end table.
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$table = $schema->getTable('page_content');
$table->changeColumn('sequence', array(
'after' => 'id' // - hire I don't know how do this?
));
$table->addIndex(array('sequence'));
}
Upvotes: 2
Views: 731
Reputation: 9582
You could execute the required straight SQL:
public function up(Schema $schema)
{
$this->addSql($sql);
}
For reference, see How to move columns in a MySQL table.
Upvotes: 3