Skip to content

Commit

Permalink
To disable doctrine migrations, use:
Browse files Browse the repository at this point in the history
    VIPSoft\DoctrineDataFixturesExtension\Extension:
        migrations: ~

To enable only application doctrine migrations, use:

    VIPSoft\DoctrineDataFixturesExtension\Extension:
        migrations: []

To enable application doctrine migrations and behat suite/profile-specific migrations, use:

    VIPSoft\DoctrineDataFixturesExtension\Extension:
        migrations:
          - path/to/suite-specific-migrations
          - path/to/more/migrations
  • Loading branch information
robocoder committed May 5, 2014
1 parent d061d4e commit 5bfe388
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ private function fetchFixtures()
*/
private function fetchMigrations()
{
if ( ! isset($this->migrations)) {
return null;
}

if (empty($this->migrations)) {
return array();
}
Expand Down Expand Up @@ -311,19 +315,23 @@ private function loadFixtures()
private function runMigrations()
{
$connection = $this->entityManager->getConnection();

/*
$container = $this->kernel->getContainer();
$outputWriter = new OutputWriter(function () {});

$configuration = new Configuration($connection, $outputWriter);
$configuration->setMigrationsNamespace();
$configuration->setMigrationsDirectory();
$configuration->setName();
$configuration->setMigrationsTableName();
$namespace = $container->getParameter('doctrine_migrations.namespace');
if ($namespace) {
$directory = $container->getParameter('doctrine_migrations.dir_name');

$migration = new Migration($configuration);
$sql = $migration->migrate(null, false);
*/
$configuration = new Configuration($connection, $outputWriter);
$configuration->setMigrationsNamespace($namespace);
$configuration->setMigrationsDirectory($directory);
$configuration->registerMigrationsFromDirectory($directory);
$configuration->setName($container->getParameter('doctrine_migrations.name'));
$configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));

$migration = new Migration($configuration);
$migration->migrate(null, false);
}

foreach ($this->migrations as $migration) {
foreach (explode("\n", trim(file_get_contents($migration))) as $sql) {
Expand Down Expand Up @@ -383,7 +391,7 @@ public function cacheFixtures()
}

$cacheDirectory = $this->kernel->getContainer()->getParameter('kernel.cache_dir');
$this->backupDbFile = $cacheDirectory . '/test_' . $this->generateHash($this->migrations, $this->fixtures) . '.db';
$this->backupDbFile = $cacheDirectory . '/test_' . $this->generateHash($this->migrations ?: array(), $this->fixtures) . '.db';
}

/**
Expand All @@ -403,7 +411,7 @@ public function reloadFixtures()
return;
}

$this->createDatabase($this->databaseFile, empty($this->migrations));
$this->createDatabase($this->databaseFile, ! isset($this->migrations));
$this->loadFixtures();

copy($this->databaseFile, $this->backupDbFile);
Expand Down

0 comments on commit 5bfe388

Please sign in to comment.