-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] register the bundle as a Doctrine Migrations provider #23
Comments
I'll take a look at it! Thanks @dkarlovi 👍 ! |
IIUC, you don't really need to do anything special expect having your bundle load a YAML config file (or via config extension / compiler pass, boils down to the same thing) which defines the path and namespace (same as in Twig). |
Hm... Our migrations are not part of any bundle, so I doubt notation similar to |
You could try doctrine_migrations:
migrations_paths:
'Netgen\Core\Migrations': '../../layouts-core/migrations' # assumes you're in vendor/netgen together maybe? Not sure if it will work, but it might. |
Will do. And I need to check if this will allow us to keep using our custom migrations table, since I'd like to keep it separate, to have more control over upgrade process of Netgen Layouts (without fears that some other unknown migration will interfere), even if it means using the path to config file. |
I think the migration table should be stable since it's managed by Doctrine, but I see your point. 👍 |
Hi! I was also hoping we could resolve this issue. However, I have a different solution. I don't know if you'll agree Edi... since you said that you'd like to keep the custom migrations table... but I very much prefer the below proposal :). There are 2 things that I'd like to see improved:
The way we solve this in Symfony's core is by hooking into the "schema system" of Doctrine. Basically, when Doctrine is building it's schema (e.g. because you're running Here is an example from Symfony: this is to add a table to the database if you're using Doctrine for caching: https://github.com/symfony/symfony/blob/6.2/src/Symfony/Bridge/Doctrine/SchemaListener/DoctrineDbalCacheAdapterSchemaSubscriber.php - the actual code that creates the schema is here - https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php#L104-L116 - and the service wiring is in DoctrineBundle: https://github.com/doctrine/DoctrineBundle/blob/5523a816c2725ad836c8c2c03243fc904c3969c2/Resources/config/orm.xml#L137-L140 Cheers! |
Hi guys, I finally played a little bit with this, so here are my findings: Adding a custom namespace to Doctrine Migrations config as @dkarlovi suggested works fine, however: When using I had a thought to create a wrapper around As for The example you provided @weaverryan uses the Schema API to add the table, but Netgen Layouts mainly uses SQL, so not really compatible with schema listeners I believe. In any case, I'm really not sure what would be the best approach here. |
Hmm, yea, one practical problem I can now see is that your migrations not only add tables, but also insert data, which isn't really compatible with schema listeners. The only option I can think of to avoid the problem where userland I'm not sure this is something layouts should prepend automatically (because if the user configured this manually later, it would replace the prepended value), but it could at least be documented with the correct regex to get it working. |
Yep, that could definitely work 👍 |
@weaverryan Does this look okay to you? |
I like it! |
https://www.goetas.com/blog/multi-namespace-migrations-with-doctrinemigrations-30/
Basically, when you do
doctrine:migrations:status
, you can see bundles with their config auto-configured, then the migration config path is not required.The text was updated successfully, but these errors were encountered: