Skip to content

Conversation

@HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Nov 12, 2025

A continuation of #524.

Unlike the previous PR, which attempted to support both migrations as services and regular migrations, this one introduces a new enable_service_migrations option, which greatly simplifies the overall implementation.

When enabled, Doctrine will fetch migrations from Symfony’s service container.

To use migrations as services, they need to be autoloadable. IMO, the best approach is to place them inside your src directory, for example:

doctrine_migrations:
+   enable_service_migrations: true
    migrations_paths:
-       'DoctrineMigrations': '%kernel.project_dir%/migrations'
+       'App\Migrations': '%kernel.project_dir%/src/Migrations'

@HypeMC HypeMC force-pushed the service-migrations branch from 444fe00 to d657913 Compare November 12, 2025 21:21
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation in docs/index.rst

@HypeMC HypeMC force-pushed the service-migrations branch from d657913 to a03b6a3 Compare November 12, 2025 23:48
@HypeMC
Copy link
Contributor Author

HypeMC commented Nov 12, 2025

@greg0ire I've updated the documentation. Please let me know if it's ok.

@greg0ire greg0ire added this to the 3.7.0 milestone Nov 14, 2025
@greg0ire greg0ire merged commit 1e380c6 into doctrine:3.7.x Nov 15, 2025
15 checks passed
@greg0ire
Copy link
Member

Thanks @HypeMC !

@HypeMC HypeMC deleted the service-migrations branch November 15, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants