Skip to content

Commit 3592645

Browse files
authored
Merge pull request #1474 from doctrine/3.8.x
Merge 3.8.x up into 3.9.x
2 parents 610092c + 1065fbe commit 3592645

13 files changed

+82
-42
lines changed

.doctrine-project.json

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"slug": "migrations",
55
"docsSlug": "doctrine-migrations",
66
"versions": [
7+
{
8+
"name": "4.0",
9+
"branchName": "4.0.x",
10+
"slug": "4.0",
11+
"upcoming": true
12+
},
713
{
814
"name": "3.9",
915
"branchName": "3.9.x",

.github/workflows/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ on:
2626
jobs:
2727
coding-standards:
2828
name: "Coding Standards"
29-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.0.1"
29+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@6.0.0"

.github/workflows/composer-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ on:
1717
jobs:
1818
composer-lint:
1919
name: "Composer Lint"
20-
uses: "doctrine/.github/.github/workflows/composer-lint.yml@5.0.1"
20+
uses: "doctrine/.github/.github/workflows/composer-lint.yml@6.0.0"

.github/workflows/continuous-integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
path: "reports"
9898

9999
- name: "Upload to Codecov"
100-
uses: "codecov/codecov-action@v4"
100+
uses: "codecov/codecov-action@v5"
101101
with:
102102
directory: reports
103103
env:

.github/workflows/release-on-milestone-closed.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
release:
1010
name: "Git tag, release & create merge-up PR"
11-
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.0.1"
11+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@6.0.0"
1212
secrets:
1313
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1414
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

docs/en/reference/configuration.rst

+23-23
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,27 @@ Please note that if you want to use the YAML configuration option, you will need
131131
132132
Here are details about what each configuration option does:
133133

134-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
135-
| Name | Required | Default | Description |
136-
+============================+============+==============================+==================================================================================+
137-
| migrations_paths<string, string> | yes | null | The PHP namespace your migration classes are located under and the path to a directory where to look for migration classes. |
138-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
139-
| table_storage | no | | Used by doctrine migrations to track the currently executed migrations |
140-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
141-
| all_or_nothing | no | false | Whether or not to wrap multiple migrations in a single transaction. |
142-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
143-
| transactional | no | true | Whether or not to wrap migrations in a single transaction. |
144-
| | | | |
145-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
146-
| migrations | no | [] | Manually specify the array of migration versions instead of finding migrations. |
147-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
148-
| check_database_platform | no | true | Whether to add a database platform check at the beginning of the generated code. |
149-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
150-
| organize_migrations | no | ``none`` | Whether to organize migration classes under year (``year``) or year and month (``year_and_month``) subdirectories. |
151-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
152-
| connection | no | null | The named connection to use (available only when ConnectionRegistryConnection is used). |
153-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
154-
| em | no | null | The named entity manager to use (available only when ManagerRegistryEntityManager is used). |
155-
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
134+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
135+
| Name | Required | Default | Description |
136+
+==================================+==========+==========+=============================================================================================================================+
137+
| migrations_paths<string, string> | yes | null | The PHP namespace your migration classes are located under and the path to a directory where to look for migration classes. |
138+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
139+
| table_storage | no | | Used by doctrine migrations to track the currently executed migrations |
140+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
141+
| all_or_nothing | no | false | Whether or not to wrap multiple migrations in a single transaction. |
142+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
143+
| transactional | no | true | Whether or not to wrap migrations in a single transaction. |
144+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
145+
| migrations | no | [] | Manually specify the array of migration versions instead of finding migrations. |
146+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
147+
| check_database_platform | no | true | Whether to add a database platform check at the beginning of the generated code. |
148+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
149+
| organize_migrations | no | ``none`` | Whether to organize migration classes under year (``year``) or year and month (``year_and_month``) subdirectories. |
150+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
151+
| connection | no | null | The named connection to use (available only when ConnectionRegistryConnection is used). |
152+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
153+
| em | no | null | The named entity manager to use (available only when ManagerRegistryEntityManager is used). |
154+
+----------------------------------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------+
156155

157156

158157
Here the possible options for ``table_storage``:
@@ -164,7 +163,7 @@ Here the possible options for ``table_storage``:
164163
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
165164
| version_column_name | no | version | The name of the column which stores the version name. |
166165
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
167-
| version_column_length | no | 191 | The length of the column which stores the version name. |
166+
| version_column_length | no | 191 | The length of the column which stores the version name. |
168167
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
169168
| executed_at_column_name | no | executed_at | The name of the column which stores the date that a migration was executed. |
170169
+----------------------------+------------+------------------------------+----------------------------------------------------------------------------------+
@@ -378,3 +377,4 @@ Make sure to create the directory where your ORM entities will be located:
378377
$ mkdir lib/MyProject/Entities
379378
380379
:ref:`Next Chapter: Migration Classes <migration-classes>`
380+

src/Generator/DiffGenerator.php

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Doctrine\Migrations\Generator\Exception\NoChangesDetected;
1313
use Doctrine\Migrations\Provider\SchemaProvider;
1414

15+
use function method_exists;
1516
use function preg_match;
1617
use function strpos;
1718
use function substr;
@@ -63,6 +64,18 @@ static function ($assetName) use ($filterExpression) {
6364

6465
$toSchema = $this->createToSchema();
6566

67+
// prior to DBAL 4.0, the schema name was set to the first element in the search path,
68+
// which is not necessarily the default schema name
69+
if (
70+
! method_exists($this->schemaManager, 'getSchemaSearchPaths')
71+
&& $this->platform->supportsSchemas()
72+
) {
73+
$defaultNamespace = $toSchema->getName();
74+
if ($defaultNamespace !== '') {
75+
$toSchema->createNamespace($defaultNamespace);
76+
}
77+
}
78+
6679
$comparator = $this->schemaManager->createComparator();
6780

6881
$upSql = $this->platform->getAlterSchemaSQL($comparator->compareSchemas($fromSchema, $toSchema));

src/Metadata/Storage/TableMetadataStorage.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ private function updateMigratedVersionsFromV1orV2toV3(): void
276276

277277
private function isAlreadyV3Format(AvailableMigration $availableMigration, ExecutedMigration $executedMigration): bool
278278
{
279-
return strpos(
280-
(string) $availableMigration->getVersion(),
281-
(string) $executedMigration->getVersion(),
282-
) !== strlen((string) $availableMigration->getVersion()) -
283-
strlen((string) $executedMigration->getVersion());
279+
return (string) $availableMigration->getVersion() === (string) $executedMigration->getVersion()
280+
|| strpos(
281+
(string) $availableMigration->getVersion(),
282+
(string) $executedMigration->getVersion(),
283+
) !== strlen((string) $availableMigration->getVersion()) -
284+
strlen((string) $executedMigration->getVersion());
284285
}
285286
}

src/Tools/Console/Command/DiffCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ protected function execute(
127127
return 3;
128128
}
129129

130-
$fqcn = $this->getDependencyFactory()->getClassNameGenerator()->generateClassName($namespace);
131-
130+
$fqcn = $this->getDependencyFactory()->getClassNameGenerator()->generateClassName($namespace);
132131
$diffGenerator = $this->getDependencyFactory()->getDiffGenerator();
133132

134133
try {
@@ -154,12 +153,12 @@ protected function execute(
154153
sprintf('Generated new migration class to "<info>%s</info>"', $path),
155154
'',
156155
sprintf(
157-
'To run just this migration for testing purposes, you can use <info>migrations:execute --up \'%s\'</info>',
156+
'To run just this migration for testing purposes, you can use <info>migrations:execute --up "%s"</info>',
158157
addslashes($fqcn),
159158
),
160159
'',
161160
sprintf(
162-
'To revert the migration you can use <info>migrations:execute --down \'%s\'</info>',
161+
'To revert the migration you can use <info>migrations:execute --down "%s"</info>',
163162
addslashes($fqcn),
164163
),
165164
'',

src/Tools/Console/Command/DumpSchemaCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ public function execute(
105105
sprintf('Dumped your schema to a new migration class at "<info>%s</info>"', $path),
106106
'',
107107
sprintf(
108-
'To run just this migration for testing purposes, you can use <info>migrations:execute --up \'%s\'</info>',
108+
'To run just this migration for testing purposes, you can use <info>migrations:execute --up "%s"</info>',
109109
addslashes($fqcn),
110110
),
111111
'',
112112
sprintf(
113-
'To revert the migration you can use <info>migrations:execute --down \'%s\'</info>',
113+
'To revert the migration you can use <info>migrations:execute --down "%s"</info>',
114114
addslashes($fqcn),
115115
),
116116
'',

tests/Metadata/Storage/TableMetadataStorageTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
use Doctrine\DBAL\Types\IntegerType;
1919
use Doctrine\DBAL\Types\StringType;
2020
use Doctrine\DBAL\Types\Types;
21+
use Doctrine\Migrations\AbstractMigration;
2122
use Doctrine\Migrations\Exception\MetadataStorageError;
23+
use Doctrine\Migrations\Metadata\AvailableMigration;
24+
use Doctrine\Migrations\Metadata\ExecutedMigration;
2225
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorage;
2326
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
2427
use Doctrine\Migrations\Version\AlphabeticalComparator;
@@ -27,6 +30,7 @@
2730
use Doctrine\Migrations\Version\Version;
2831
use PHPUnit\Framework\TestCase;
2932
use Psr\Log\Test\TestLogger;
33+
use ReflectionClass;
3034

3135
use function sprintf;
3236

@@ -400,4 +404,21 @@ public function testGetSql(): void
400404

401405
self::assertCount(0, $this->connection->fetchAllAssociative($sql));
402406
}
407+
408+
public function testIsAlreadyV3FormatDoesntMissTheSameVersions(): void
409+
{
410+
$availableMigration = new AvailableMigration(
411+
new Version('Foo\\Version1234'),
412+
$this->createMock(AbstractMigration::class),
413+
);
414+
$executedMigrationV3 = new ExecutedMigration(new Version('Foo\\Version1234'));
415+
$executedMigrationOlder = new ExecutedMigration(new Version('Version1234'));
416+
417+
$reflection = new ReflectionClass(TableMetadataStorage::class);
418+
$method = $reflection->getMethod('isAlreadyV3Format');
419+
$method->setAccessible(true);
420+
421+
self::assertTrue($method->invokeArgs($this->storage, [$availableMigration, $executedMigrationV3]));
422+
self::assertFalse($method->invokeArgs($this->storage, [$availableMigration, $executedMigrationOlder]));
423+
}
403424
}

tests/Tools/Console/Command/DiffCommandTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ public function testExecute(): void
8282
self::assertSame([
8383
'Generated new migration class to "/path/to/migration.php"',
8484
'',
85-
'To run just this migration for testing purposes, you can use migrations:execute --up \'FooNs\\\\Version1234\'',
85+
'To run just this migration for testing purposes, you can use migrations:execute --up "FooNs\\\\Version1234"',
8686
'',
87-
'To revert the migration you can use migrations:execute --down \'FooNs\\\\Version1234\'',
87+
'To revert the migration you can use migrations:execute --down "FooNs\\\\Version1234"',
8888
], array_map(trim(...), explode("\n", trim($output))));
8989
}
9090

tests/Tools/Console/Command/DumpSchemaCommandTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ public function testExecute(): void
9191
[
9292
'Dumped your schema to a new migration class at ""',
9393
'',
94-
'To run just this migration for testing purposes, you can use migrations:execute --up \'FooNs\\\\Version1234\'',
94+
'To run just this migration for testing purposes, you can use migrations:execute --up "FooNs\\\\Version1234"',
9595
'',
96-
'To revert the migration you can use migrations:execute --down \'FooNs\\\\Version1234\'',
96+
'To revert the migration you can use migrations:execute --down "FooNs\\\\Version1234"',
9797
'',
9898
'To use this as a rollup migration you can use the migrations:rollup command.',
9999
],

0 commit comments

Comments
 (0)