DoctrineMigrationsBundle
DoctrineMigrationsBundle copied to clipboard
Migration diff command throws error "The schema provider is not available" on v3.1.1
After upgrading from v3.1.0 to 3.1.1, the command doctrine:migrations:diff throws the error "The schema provider is not available"
Here is the stack trace:

Same problem here, downgraded to 3.1.0 and everything works again
Do you have multiple entity managers or did you define the connection or entity manager in your configuration files?
I have done the same action (downgraded to 3.1.0) done by @Thiplow (Thanks :) ) to fix the problem.
@goetas I have multiple connections in my application.
https://github.com/doctrine/DoctrineMigrationsBundle/compare/3.1.0...3.1.1, I think that the problem is in DependencyInjection/CompilerPass/ConfigureDependencyFactoryPass.php
Thank you for your help.
Do you have multiple entity managers or did you define the connection or entity manager in your configuration files?
@goetas I've got a single connection in my application and it's defined in the config files
@omarboussarsar @allD245 can you share the doctrine migrations configs that you are using?
@goetas
doctrine_migrations:
storage:
table_storage:
table_name: migration_versions
migrations_paths:
'DoctrineMigrations': 'src/Migrations'
connection: default
here's my doctrine config as well
doctrine:
dbal:
# configure these for your database server
# use postgresql for PostgreSQL
# use sqlite for SQLite
driver: 'mysql'
server_version: '5.7'
# only needed for MySQL
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
JMoseCommandSchedulerBundle: ~
ApplicationSonataMediaBundle: ~
SonataMediaBundle: ~
@allD245 doctrine:migrations:diff needs the entity manager to be able to generate the ORM schema diff.
I think that your config file should be:
doctrine_migrations:
storage:
table_storage:
table_name: migration_versions
migrations_paths:
'DoctrineMigrations': 'src/Migrations'
em: default
@goetas replacing connection with em and setting the value to default in my doctrine_migrations config fixes the doctrine:migrations:diff command for me on v3.1.1. Thanks!
@allD245 the diff command indeed requires using an entity manager, unless you provide a custom schema provider. The builtin schema provider relies on the entity manager providing a schema.
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_pgsql'
server_version: '12.6'
charset: UTF8
admin:
url: '%env(resolve:DATABASE_ADMIN_URL)%'
driver: 'pdo_pgsql'
server_version: '12.6'
charset: UTF8
orm:
auto_generate_proxy_classes: '%doctrine_method%'
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
doctrine_migrations:
connection: admin
migrations_paths:
'Application\Migrations': '%kernel.project_dir%/migrations'
storage:
table_storage:
table_name: 'migration_versions'
@goetas Thanks for your feedback. The solution proposed for @allD245 is not good for my example because I don't need to have many entity managers.
Hi everyone.
I was having this error in a project. It has defined 2 connections, 1 for migrations. After reading this issue I have solved the error by defining an entitymanager that uses the connection defined for migrations, and using that EM in the doctrine_migrations.yaml:
doctrine_migrations:
# This was enough until version 3.1.1
# connection: migrations
# Now this is what the project needs
em: migrations_em
...
doctrine:
dbal:
default_connection: default
connections:
default:
...
migrations:
...
orm:
default_entity_manager: default
auto_generate_proxy_classes: false
entity_managers:
default:
...
migrations_em:
# If not specified, it uses 'default_connection' value
connection: migrations
...
@omarboussarsar your migrations config file should be
doctrine_migrations:
em: default
(or even just omit the em/connection parameter)
The admin connection should be used only for production i guess, so:
doctrine_migrations:
connection: admin
should be in config/packages/prod/doctrine_migrations.yaml
If you are using different connections even locally, then when running the migrations you should specify the --em parameter when running the diff command.
Hey @goetas Your tip worked fine for me. Thanks :)