Skip to content

Commit

Permalink
Merge branch '3.7.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.7.x:
  Update to box 4.4.0
  Use github actions format for BC check (doctrine#1364)
  Apply PR feedback on the upgrade note
  Deprecate using `--all-or-nothing` with values
  Allow Symfony 7 (doctrine#1361)
  Trigger the build on download script change
  build: Update Box
  • Loading branch information
derrabus committed Oct 29, 2023
2 parents d591226 + 8022851 commit 95ec0f3
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bc-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
run: composer require --dev roave/backward-compatibility-check

- name: Run roave/backward-compatibility-check.
run: vendor/bin/roave-backward-compatibility-check
run: vendor/bin/roave-backward-compatibility-check --format=github-actions
2 changes: 2 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- .github/workflows/continuous-integration.yml
- composer.*
- download-box.sh
- lib/**
- phpunit.xml.dist
- tests/**
Expand All @@ -16,6 +17,7 @@ on:
paths:
- .github/workflows/continuous-integration.yml
- composer.*
- download-box.sh
- lib/**
- phpunit.xml.dist
- tests/**
Expand Down
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Upgrade to 3.6

## Console
- The `--all-or-nothing` option for `migrations:migrate` does not accept a value anymore, and passing it a
value will generate a deprecation. Specifying `--all-or-nothing` will wrap all the migrations to be
executed into a single transaction, regardless of the specified configuration.



# Upgrade to 3.1

- The "version" is the FQCN of the migration class (existing entries in the migrations table will be automatically updated).
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"doctrine/deprecations": "^0.5.3 || ^1",
"doctrine/event-manager": "^1.2 || ^2.0",
"psr/log": "^1.1.3 || ^2 || ^3",
"symfony/console": "^5.4 || ^6.0",
"symfony/stopwatch": "^5.4 || ^6.0",
"symfony/var-exporter": "^6.2"
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0",
"symfony/var-exporter": "^6.2 || ^7.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
Expand All @@ -46,9 +46,9 @@
"phpstan/phpstan-strict-rules": "^1.4",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^10.3",
"symfony/cache": "^5.4 || ^6.0",
"symfony/process": "^5.4 || ^6.0",
"symfony/yaml": "^5.4 || ^6.0"
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"symfony/process": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"conflict": {
"doctrine/orm": "<2.12"
Expand Down
2 changes: 1 addition & 1 deletion download-box.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

if [ ! -f box.phar ]; then
wget https://github.com/box-project/box/releases/download/3.16.0/box.phar -O box.phar
wget https://github.com/box-project/box/releases/download/4.4.0/box.phar -O box.phar
fi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\Migrations\Tools\Console;

use Doctrine\Deprecations\Deprecation;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\MigratorConfiguration;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -28,16 +29,30 @@ public function getMigratorConfiguration(InputInterface $input): MigratorConfigu

private function determineAllOrNothingValueFrom(InputInterface $input): bool|null
{
if (! $input->hasOption('all-or-nothing')) {
return null;
$allOrNothingOption = null;
$wasOptionExplicitlyPassed = $input->hasOption('all-or-nothing');

if ($wasOptionExplicitlyPassed) {
$allOrNothingOption = $input->getOption('all-or-nothing');
}

$allOrNothingOption = $input->getOption('all-or-nothing');
if ($wasOptionExplicitlyPassed && $allOrNothingOption !== null) {
Deprecation::trigger(
'doctrine/migrations',
'https://github.com/doctrine/migrations/issues/1304',
<<<'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
DEPRECATION,
);
}

if ($allOrNothingOption === 'notprovided') {
return null;
}

return (bool) ($allOrNothingOption ?? true);
return (bool) ($allOrNothingOption ?? false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
Expand Down Expand Up @@ -42,6 +43,8 @@

class MigrateCommandTest extends MigrationTestCase
{
use VerifyDeprecations;

private DependencyFactory $dependencyFactory;
private Configuration $configuration;
private CommandTester $migrateCommandTester;
Expand Down Expand Up @@ -340,7 +343,7 @@ public function testExecuteMigrateDown(): void
*
* @dataProvider allOrNothing
*/
public function testExecuteMigrateAllOrNothing(bool $default, array $input, bool $expected): void
public function testExecuteMigrateAllOrNothing(bool $default, array $input, bool $expected, bool $expectDeprecation = true): void
{
$migrator = $this->createMock(DbalMigrator::class);
$this->dependencyFactory->setService(Migrator::class, $migrator);
Expand All @@ -355,6 +358,12 @@ public function testExecuteMigrateAllOrNothing(bool $default, array $input, bool
return ['A'];
});

if ($expectDeprecation) {
$this->expectDeprecationWithIdentifier(
'https://github.com/doctrine/migrations/issues/1304',
);
}

$this->migrateCommandTester->execute(
$input,
['interactive' => false],
Expand All @@ -363,7 +372,7 @@ public function testExecuteMigrateAllOrNothing(bool $default, array $input, bool
self::assertSame(0, $this->migrateCommandTester->getStatusCode());
}

/** @psalm-return Generator<array{bool, array<string, bool|int|string|null>, bool}> */
/** @psalm-return Generator<array{0: bool, 1: array<string, bool|int|string|null>, 2: bool, 3?: bool}> */
public static function allOrNothing(): Generator
{
yield [false, ['--all-or-nothing' => false], false];
Expand All @@ -373,7 +382,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], true];
yield [false, ['--all-or-nothing' => null], false, false];

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

0 comments on commit 95ec0f3

Please sign in to comment.