Created
September 20, 2012 11:19
-
-
Save ludekstepan/3755289 to your computer and use it in GitHub Desktop.
Example of container aware migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) | |
{ | |
// ... | |
} | |
} |
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
I'm getting an exception trying to do this.