doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.68k stars 385 forks source link

`--all-or-nothing` option is very confusing #1279

Closed lazka closed 1 year ago

lazka commented 2 years ago
Q A
Version 3.1.5

I was running the following:

bin/console doctrine:migrations:migrate --em=my_em --no-interaction --all-or-nothing

Turns out just passing --all-or-nothing does not do anything, you have to pass --all-or-nothing=1 or --all-or-nothing=0 for it to have any effect: https://github.com/doctrine/migrations/blob/5713b45c933122e509d9b31c767b420c3dfed399/lib/Doctrine/Migrations/Tools/Console/ConsoleInputMigratorConfigurationFactory.php#L24 (it will result in null, then fall back to the configuration)

This is very confusing imo and there are lots of examples out there that just pass --all-or-nothing.

Am I missing something?

greg0ire commented 2 years ago

What do the docs say?

agustingomes commented 1 year ago

I created a PR to correct the docs example: https://github.com/doctrine/migrations/pull/1296 as I just found this issue while working on automating Doctrine migrations in my work context.

@greg0ire what do you think?

greg0ire commented 1 year ago

I'll try to look into it but have you seen https://github.com/doctrine/migrations/pull/1161 ? Before it was merged, I think the --all-or-nothing must have been working as expected, because back then the code looked a lot like the code for the dry-run option (which works as expected, right?)

I think the code in that MR might be wrong. It should not fall back on the configuration as soon as $input->hasOption('all-or-nothing') returns true, right?

greg0ire commented 1 year ago

Cc @grachevko

agustingomes commented 1 year ago

Added a test case in the PR confirming the current (and unexpected) behavior.