-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Configuration used by CLI commands is ignored #311
Comments
doctrine:migrations:migrate should give you an error since the config parameter is not available at all in symfony. Can you please post the whole command line rather than the single parts? |
What do you mean? The command in question is the one from the issue description:
With v2, this worked fine, even if a Symfony app on which I run this does not use or configure Migrations, and any configured migrations on app level are simply ignored. On v3, Migrations seem to use the global app config no matter what. |
Yes they are per application. In which situation do you have multiple migrations in a single application? |
I will copy paste my answer from #310 and close that one, because that one is pretty much false issue, I was too quick to open it, before I ran into this one: You have a Symfony app, fairly regular, doesn't need access to a database so no Doctrine is used at all. If you wish to install our bundle, which uses Migrations to manage the DB tables, one of the steps is to run Migrations. To make the install process easier for the users, and to not require them to add Migrations config to their main
where the yaml file is:
In v2, this works without issues, even if the Symfony app you're installing the bundle on, never even used Migrations and has no previous config. The command will just take the config from the provided file and run it. This does not work on v3 any more, where our custom configuration specified by |
Basically, what we had before was the possibility to manage and run migrations specifically for our bundle, without ever having to think about if running the |
So from my understanding, what is happening in your case is that you were using the bundle for your core app while other parts of the system were using a side effect of the bundle that was allowing you to specify an alternative path for the configuration file while keeping the initial database connection defined globally. Am I right? Personally I feel that it bends a bit what the bundle was supposed to do (I mean, taking some configs from additional files outside of symfony control). |
Were this other parts of the system running migrations on the same database? If yes, Were there risks of collision with migration names? Or possible dependencies with your bundle? |
Well, not just taking them from the additional files, but replacing the Symfony config entirely with the config specified in CLI, that is the whole point, and from my understanding, that was precisely the intention before. Our config uses a custom migrations table name ( For example, our bundle works without issues with Sylius. Sylius install/upgrade process uses their own migrations configured in Symfony, using |
Can't you in this case use the |
We can, but it makes it automatically more complicated:
I can't think of a reason why this feature stopped working in v3. The |
The The whole idea behind the multi-ns migrations was to have doctrine "owning" the process of migrations, but allowing bundles to provide migrations. The workflow you are using seems working, but it seems to me that is relatively manual as each "module" had its own set of migrations, and running them was done issuing multiple doctrine commands. It seems to me that also managing dependencies between migrations was not possible or manually done. In doctrine migrations, the whole set of dependencies and configurations is resolved at container-compile-time. Not sure how your workflow could be replicated with v3. |
A possibile solution would be to replace only a subset of the configs from the dependency factory if the configuration parameter is provided... |
Maybe introducing some kind of "named" configuration sets would be the way to go. Similar how Doctrine DBAL has a main DB connection, and other, named DB connections, and each connection has it's set of parameters.
That's true, but our product is usually upgraded independent from the rest of the system and has its own clear instructions which detail the exact command that needs to be run, and so far our users did not care that it is somehow different from main migrations, if they even exist. The command worked, and it upgraded our DB tables and that's what matters to our users. What matters more is the fact that upgrading our product is a self-contained process and has no possible way to break other parts of their system by, let's say, running some other migrations by mistake.
Maybe, but in our case, our migrations are completely separate from global app migrations, have their own table and absolutely no dependencies on global app migrations, so no worries there.
I think that only replacing subset might be confusing. What would be the issue with replacing everything? I definitely need the possibility to specify my own migration paths and a custom migration versions table ( |
Can you please test doctrine/migrations#959 and let me know if it solves the issue for you? |
Hi @goetas ! There's definitelly progress! First, Migrations complained again that no migrations are configured, which means you can't activate the bundle without having some configuration, which is our case. Maybe #310 shouldn't have been closed? I solved this by adding some dummy config in Next, I tried introducting errors in our config, and Migrations, as expected complained about them. This is good. However, once the config file was correct, I got the error message that I need to run
My DB charset is I set the After that, I could run my migrations without issues. |
The issue relative to the sql error is tracked in doctrine/migrations#960 |
@emodric I have updated doctrine/migrations#959 with what should be the final version. Could you please test it again and let me know if it works for you? |
@goetas Everything works fine, thanks! |
Solved in doctrine/migrations#959 |
Thank you @goetas ! |
It seems that CLI commands ignore the
--configuration
parameter passed to them and instead use the globally configured migrations.My
config/packages/doctrine_migrations.yaml
(src/Migrations
is an empty folder):My configuration used with CLI (notice how I added
name
as a test, which would make the config fail to parse), also tried adding the root configdoctrine_migrations
:So when I run:
Instead of ignoring the globally configured migrations in favor of the config provided via CLI, I get the following:
This indicates that the global config is used (the one without migrations) instead of the CLI one.
The text was updated successfully, but these errors were encountered: