0

I'm trying to generate and execute migrations using doctrine/doctrine-migrations-bundle.

Project specs:

  • Project deployed in docker. Mapping configured successfully.
  • Framework: symfony.
  • Kernel::getProjectDir() overrided successfully.
  • Project dependencies (not all, only important for this topic) from composer.json:
    • "doctrine/doctrine-bundle": "^2.1",
      "doctrine/doctrine-migrations-bundle": "^3.2",
      "doctrine/orm": "^2.7",
      "symfony/framework-bundle": "5.1.*",
      

My project has migrations for two databases. There are 2 config files for this. An example of one of them for understanding (absolute path in container /opt/app/config/packages/migrations/some_config.yaml):

custom_template: '%kernel.project_dir%/config/migration_template.txt' # <- this not works
# custom_template: '/opt/app/config/migration_template.txt' # <- this works
em: some_em
transactional: false
migrations_paths:
  'DoctrineMigrations': '%kernel.project_dir%/src/DoctrineMigrations' # <- this not works
  #'DoctrineMigrations': '/opt/app/src/DoctrineMigrations' # <- this works

Problem:

I'm trying to generate migration, using following command:

bin/console doctrine:migrations:generate --configuration='/opt/app/config/packages/migrations/some_config.yaml'

An exception is thrown with an message:

 The specified template "%kernel.project_dir%/config/migration_template.txt" cannot be found or is not readable

For absolute path everything works fine.

I have tried to debug doctrine-migrations package code and found, that path %kernel.project_dir%/config/migration_template.txt does not turn into /opt/app/config/migration_template.txt

Gregory Sysoev
  • 173
  • 1
  • 15

1 Answers1

0

I think the problem is that the command is implemented in the doctrine/migrations lib and is unaware of Symfony, and therefore doesn't know about container parameters. The Doctrine migrations docs have an example for such a path, so you might try this:

'./src/DoctrineMigrations'

(didn't try myself though).

The relevant part in the docs is here: https://www.doctrine-project.org/projects/doctrine-migrations/en/3.6/reference/configuration.html#configuration

umulmrum
  • 153
  • 1
  • 8