-
Notifications
You must be signed in to change notification settings - Fork 27
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
Store migrations inside bundles and collect them from installed bundles? #22
Comments
From my point of view this is not a good idea. Letting bundles control the schema of your DB is a dangerous path to walk. As some people said in doctrine/DoctrineMigrationsBundle#152, migrations are tied to your application and specific to it. |
I know that this is dangerous and should be used with caution. I try to explain my reasons about why I propose this approach. |
@caciobanu , can you, please, comment my explanation of approach? |
For me I think it could be good. I have thought of having this system before. To be honest I was not able to follow the wholle argument in doctrine/DoctrineMigrationsBundle#152 very well. For us our application is made up of many bundles. We use it to keep things separate. Having migrations per bundle makes a lot of sense. But I have not investigated the solution. The security issue is true for bundles, and open source software in general, regardless of database access. Someone could write a bundle that sends a Besides, when I integrate a bundle I will use it first in development. The bundle will come with instructions. It will say 'run the migrations'. It should not be a problem to run in development, and I will know what it does. If I stop using the bundle then the bundle README could say: "Use this mongodb syntax to remove database tables created by this bundle" or something else similar. We can help with security by adding something like |
Security risks will still be there but I was also thinking about the behavior to be opt-in through configuration to give this feature a try. Maybe some some warnings from commands would be great :) |
@watari - do you have an implementation in mind? Could you send in a PR? I presume we would need a container compilation step that:
|
@redthor, I have some ideas about implementation.
Example of configs:
About params |
Good evening, I'm also searching for that feature. The main (cons) argument in doctrine/DoctrineMigrationsBundle#152 was: Database schema belong to application, not to bundles... Short answer Long answer
Those task could be trigggered automatically through composer plugin or whatever... Of course, operating in such way (modular) impose a stric policy: Migrations from a specific module MUST never do any change on a table schema provided by other modules. Right now, it is not possible to process this way and that is a bit sad. From my point of view, each module should be able to configure specific namespace for its migration and target them through CLI: ./vendor/bin/doctrine-module migrations:migrate --namespace modulename
... |
@watari the config looks good but just a couple of suggestions. Instead of With the @nuxwin I agree that I don't think the argument against having this feature is strong enough. I can see why you would want it. @watari is suggesting (I think) that if the config file contains the bundle then the migrations bundle will process it. You are suggesting that there needs to be a command line argument for each bundle explicitly. I added that the use would need to say Perhaps we say this:
If you want to run it for two bundles:
You cannot supply Lastly, I am working at refactoring how we create the configuration for migrations. There will be no change to the config file, just how the I will finish more updates the next week and then that may be a better place to start this new feature. |
@redthor , @caciobanu , I forked your extensions and modified logic for bundles support. Shortly about changes.
mongodb-migrations-bundle repository
If all will be ok, then I maybe refactor some other parts of libs code that I meet on my way. |
Any chance something like this will be implemented / merged? As of Symfony 4 everything should be a bundle and we have a huge customer app where business logic and data models reside in their respective bundles. Each bundle is responsible for it's own data and migration. Including by namespace or path for security is fine and IMHO sufficient. You would need to register the extra bundles within Symfony anyway before they could be detected, so it's unlikely to happen that a 3rd party bundle suddenly ships a malicious code somewhere in it's dependencies. |
Can this logic be implemented in scope of the bundle? It can be very handy in some cases.
Similar question was aroused in doctrine/DoctrineMigrationsBundle
The text was updated successfully, but these errors were encountered: