8

I am trying to setup doctrine migrations on top of silex framework. I installed it through composer.

"doctrine/dbal": "2.3.*",
"doctrine/migrations": "dev-master",

My console file:

...
$app['composer_loader']->add('Doctrine\DBAL\Migrations', __DIR__.'/../vendor/doctrine/migrations/lib/');

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    "db" => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($app['db']),
    "dialog" => new \Symfony\Component\Console\Helper\DialogHelper(),
));
$console->setHelperSet($helperSet);

$console->addCommands(array(
    // Migrations Commands
    new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
    new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
    new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
    new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
    new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
    new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand()
));

$console->run();

However when I run migrations:status It outputs:

C:\htdocs\bitvenda\app>php console.php migrations:status

  [Doctrine\DBAL\Migrations\MigrationException]
  Migrations namespace must be configured in order to use Doctrine migrations
  .

What I am doing wrong?

dextervip
  • 4,999
  • 16
  • 65
  • 93
  • 1
    Dextervip, take a look on [this other issue][1], it might solver your issue. [1]: http://stackoverflow.com/questions/10620794/doctrine-migrations-2-zend-framework-2-is-it-possibile – medina May 19 '13 at 23:38
  • @medina You are right, I missed it. Thank you. Do you know if is there any way to set default path to config file? – dextervip May 20 '13 at 00:03
  • great! I've notice you figured it out yourself.. have fun! =) – medina May 20 '13 at 00:40

1 Answers1

10

As @medina commented. I missed the configuration file. I created the yml config file as below:

name: Doctrine Migrations
migrations_namespace: DoctrineMigrations
table_name: doctrine_migration_versions
migrations_directory: /data/DoctrineMigrations

And I passed the configuration file path as argument to get it working.

php console.php migrations:status --configuration=config/migrations.yml

To avoid passing it all the time, I changed working script dir to the same dir as the configuration file so that doctrine migrations loads it automatically

chdir(__DIR__.'/config');
dextervip
  • 4,999
  • 16
  • 65
  • 93