Skip to content

Instantly share code, notes, and snippets.

@ludekstepan
Created September 20, 2012 11:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludekstepan/3755289 to your computer and use it in GitHub Desktop.
Save ludekstepan/3755289 to your computer and use it in GitHub Desktop.
Example of container aware migration
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20120920130854 extends AbstractMigration
{
public function up(Schema $schema)
{
// ...
$container = $this->version->getConfiguration()->getContainer();
$em = $container->get('doctrine.orm.entity_manager');
// ... use EntityManager and other services
}
public function down(Schema $schema)
{
// ...
}
}
@chok
Copy link

chok commented Mar 25, 2013

I had the same issue because of using sf 2.0 and not integrated in 2.0.x-dev of composer package.

You can apply the pull request in your own fork/version to have this working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment