Skip to content

Commit eeb16a3

Browse files
committed
GH-1443: fix --all-or-nothing default behavior
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
1 parent 4fc8b9d commit eeb16a3

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

docs/en/reference/configuration.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,9 @@ You can also set this option from the command line with the ``migrate`` command
249249
250250
$ ./vendor/bin/doctrine-migrations migrate --all-or-nothing
251251
252-
If you have it enabled at the configuration level and want to change it for an individual migration you can
253-
pass a value of ``0`` or ``1`` to ``--all-or-nothing``.
254-
255-
.. code-block:: sh
252+
.. note::
256253

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

259256
Connection Configuration
260257
------------------------

lib/Doctrine/Migrations/Tools/Console/ConsoleInputMigratorConfigurationFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ private function determineAllOrNothingValueFrom(InputInterface $input): bool|nul
4545
<<<'DEPRECATION'
4646
Context: Passing values to option `--all-or-nothing`
4747
Problem: Passing values is deprecated
48-
Solution: If you need to disable the behavior, omit the option,
49-
otherwise, pass the option without a value
48+
Solution: how we should deal with this option being `true` in config but user want to disable it in command line for 4.x?
5049
DEPRECATION,
5150
);
5251
}
5352

5453
return match ($allOrNothingOption) {
5554
self::ABSENT_CONFIG_VALUE => null,
56-
null => false,
55+
null => true,
5756
default => (bool) $allOrNothingOption,
5857
};
5958
}

tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ public function testExecuteCancel(): void
172172
self::assertSame(1, $this->executeCommandTester->getStatusCode());
173173
}
174174

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

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

185185
return ['A'];
186186
});

tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public static function allOrNothing(): Generator
381381
yield [false, ['--all-or-nothing' => true], true];
382382
yield [false, ['--all-or-nothing' => 1], true];
383383
yield [false, ['--all-or-nothing' => '1'], true];
384-
yield [false, ['--all-or-nothing' => null], false, false];
384+
yield [false, ['--all-or-nothing' => null], true, false];
385385

386386
yield [true, ['--all-or-nothing' => false], false];
387387
yield [true, ['--all-or-nothing' => 0], false];

0 commit comments

Comments
 (0)