Skip to content

Commit

Permalink
GH-1443: fix --all-or-nothing default behavior
Browse files Browse the repository at this point in the history
As result of some past changes to improve the way the option was inferred, several attempts to build a mechanism to handle the absence of value of this option were built via the following commits:

4da00c5
5335951
5038099
799f16d
f726a5f

This commit leverages all the iterative improvements introduced along the way, and setting the correct value when the option is correctly specified.

This should bring the behavior inline with what is currently documented, while additionally adding a documentation deprecation informing users that passing a value to that option won't be allowed in 4.x
  • Loading branch information
agustingomes committed Aug 23, 2024
1 parent 4fc8b9d commit eeb16a3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
7 changes: 2 additions & 5 deletions docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,9 @@ You can also set this option from the command line with the ``migrate`` command
$ ./vendor/bin/doctrine-migrations migrate --all-or-nothing
If you have it enabled at the configuration level and want to change it for an individual migration you can
pass a value of ``0`` or ``1`` to ``--all-or-nothing``.

.. code-block:: sh
.. note::

$ ./vendor/bin/doctrine-migrations migrate --all-or-nothing=0
Passing options to --all-or-nothing is deprecated from 3.7.x, and will not be allowed in 4.x

Connection Configuration
------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ private function determineAllOrNothingValueFrom(InputInterface $input): bool|nul
<<<'DEPRECATION'
Context: Passing values to option `--all-or-nothing`
Problem: Passing values is deprecated
Solution: If you need to disable the behavior, omit the option,
otherwise, pass the option without a value
Solution: how we should deal with this option being `true` in config but user want to disable it in command line for 4.x?
DEPRECATION,
);
}

return match ($allOrNothingOption) {
self::ABSENT_CONFIG_VALUE => null,
null => false,
null => true,
default => (bool) $allOrNothingOption,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public function testExecuteCancel(): void
self::assertSame(1, $this->executeCommandTester->getStatusCode());
}

public function testExecuteAllOrNothingDefaultsToFalse(): void
public function testExecuteAllOrNothingDefaultsToTrue(): void
{
$this->executeCommandTester->setInputs(['yes']);

$this->migrator
->expects(self::once())
->method('migrate')
->willReturnCallback(static function (MigrationPlanList $planList, MigratorConfiguration $configuration): array {
self::assertFalse($configuration->isAllOrNothing());
self::assertTrue($configuration->isAllOrNothing());

return ['A'];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public static function allOrNothing(): Generator
yield [false, ['--all-or-nothing' => true], true];
yield [false, ['--all-or-nothing' => 1], true];
yield [false, ['--all-or-nothing' => '1'], true];
yield [false, ['--all-or-nothing' => null], false, false];
yield [false, ['--all-or-nothing' => null], true, false];

yield [true, ['--all-or-nothing' => false], false];
yield [true, ['--all-or-nothing' => 0], false];
Expand Down

0 comments on commit eeb16a3

Please sign in to comment.