From e56dc4f124c9d637290ebd7ca5f30c76c2649fef Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 19 Mar 2026 13:32:41 +0700 Subject: [PATCH 1/9] Use `newMigrationPath` and `newMigrationNamespace` if `sourceNamespaces` and `sourcePaths` are not specified --- docs/guide/en/usage-standalone.md | 8 ++- docs/guide/en/usage-with-yii-console.md | 4 ++ docs/guide/pt-BR/usage-standalone.md | 8 ++- docs/guide/pt-BR/usage-with-yii-console.md | 4 ++ src/Service/MigrationService.php | 52 ++++++++++++++----- .../Command/AbstractUpdateCommandTest.php | 50 +++++++++++++++--- 6 files changed, 104 insertions(+), 22 deletions(-) diff --git a/docs/guide/en/usage-standalone.md b/docs/guide/en/usage-standalone.md index 4db372a0..8e683ee7 100644 --- a/docs/guide/en/usage-standalone.md +++ b/docs/guide/en/usage-standalone.md @@ -43,9 +43,13 @@ use Yiisoft\Injector\Injector; /** @var ConnectionInterface $database */ $migrator = new Migrator($database, new NullMigrationInformer()); $migrationService = new MigrationService($database, new Injector(), $migrator); -$migrationService->setSourcePaths([dirname(__DIR__, 2), 'migrations']); +$migrationService->setNewMigrationPath(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'migrations'); ``` +> [!NOTE] +> If `sourceNamespaces` and `sourcePaths` are not specified, `newMigrationNamespace` or `newMigrationPath` will be used +> to find migrations. + Then initialize the command for using without CLI. For example, for applying migrations it will be `UpdateCommand`: ```php @@ -55,7 +59,7 @@ use Yiisoft\Db\Migration\Command\UpdateCommand; use Yiisoft\Db\Migration\Runner\UpdateRunner; $command = new UpdateCommand(new UpdateRunner($migrator), $migrationService, $migrator); -$command->setHelperSet(new HelperSet(['queestion' => new QuestionHelper()])); +$command->setHelperSet(new HelperSet(['question' => new QuestionHelper()])); ``` And, finally, run the command: diff --git a/docs/guide/en/usage-with-yii-console.md b/docs/guide/en/usage-with-yii-console.md index a82e76d8..de282081 100644 --- a/docs/guide/en/usage-with-yii-console.md +++ b/docs/guide/en/usage-with-yii-console.md @@ -33,6 +33,10 @@ Add to `config/console/params.php`: ... ``` +> [!NOTE] +> If `sourceNamespaces` and `sourcePaths` are not specified, `newMigrationNamespace` or `newMigrationPath` will be used +> to find migrations. + Execute `composer du` in console to rebuild the configuration. Now we have the `yiisoft/db-migration` package configured and it can be called in the console. diff --git a/docs/guide/pt-BR/usage-standalone.md b/docs/guide/pt-BR/usage-standalone.md index 78fb7c1b..12218499 100644 --- a/docs/guide/pt-BR/usage-standalone.md +++ b/docs/guide/pt-BR/usage-standalone.md @@ -43,9 +43,13 @@ use Yiisoft\Injector\Injector; /** @var ConnectionInterface $database */ $migrator = new Migrator($database, new NullMigrationInformer()); $migrationService = new MigrationService($database, new Injector(), $migrator); -$migrationService->setSourcePaths([dirname(__DIR__, 2), 'migrations']); +$migrationService->setNewMigrationPath(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'migrations'); ``` +> [!NOTE] +> Se `sourceNamespaces` e `sourcePaths` não forem especificados, `newMigrationNamespace` ou `newMigrationPath` serão +> usados para encontrar as migrações. + Em seguida, inicialize o comando para usar sem CLI. Por exemplo, para aplicar migrações será `UpdateCommand`: ```php @@ -55,7 +59,7 @@ use Yiisoft\Db\Migration\Command\UpdateCommand; use Yiisoft\Db\Migration\Runner\UpdateRunner; $command = new UpdateCommand(new UpdateRunner($migrator), $migrationService, $migrator); -$command->setHelperSet(new HelperSet(['queestion' => new QuestionHelper()])); +$command->setHelperSet(new HelperSet(['question' => new QuestionHelper()])); ``` E, por fim, execute o comando: diff --git a/docs/guide/pt-BR/usage-with-yii-console.md b/docs/guide/pt-BR/usage-with-yii-console.md index 347797c0..90f3186a 100644 --- a/docs/guide/pt-BR/usage-with-yii-console.md +++ b/docs/guide/pt-BR/usage-with-yii-console.md @@ -33,6 +33,10 @@ Adicione em `config/console/params.php`: ... ``` +> [!NOTE] +> Se `sourceNamespaces` e `sourcePaths` não forem especificados, `newMigrationNamespace` ou `newMigrationPath` serão +> usados para encontrar as migrações. + Execute `composer du` no console para reconstruir a configuração. Agora temos o pacote [`yiisoft/db-migration`](https://github.com/yiisoft/db-migration) configurado e ele pode ser chamado no console. diff --git a/src/Service/MigrationService.php b/src/Service/MigrationService.php index f6077f47..3e3d1983 100644 --- a/src/Service/MigrationService.php +++ b/src/Service/MigrationService.php @@ -96,9 +96,13 @@ public function before(string $commandName): int } break; case 'migrate:up': - if (empty($this->sourceNamespaces) && empty($this->sourcePaths)) { + if (empty($this->sourceNamespaces) + && empty($this->sourcePaths) + && empty($this->newMigrationNamespace) + && empty($this->newMigrationPath) + ) { $this->io?->error( - 'At least one of `sourceNamespaces` or `sourcePaths` should be specified.', + 'At least one of `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace` or `newMigrationPath` should be specified.', ); return Command::INVALID; @@ -124,15 +128,7 @@ public function getNewMigrations(): array $applied[trim($class, '\\')] = true; } - $migrationPaths = []; - - foreach ($this->sourcePaths as $path) { - $migrationPaths[] = [$path, '']; - } - - foreach ($this->sourceNamespaces as $namespace) { - $migrationPaths[] = [$this->getNamespacePath($namespace), $namespace]; - } + $migrationPaths = $this->findSourcePaths(); $migrations = []; foreach ($migrationPaths as $item) { @@ -394,7 +390,7 @@ private function makeMigrationInstance(string $class): object if (!str_contains($class, '\\')) { $isIncluded = false; - foreach ($this->sourcePaths as $path) { + foreach ($this->findSourcePaths() as [$path]) { $file = $path . DIRECTORY_SEPARATOR . $class . '.php'; if (is_file($file)) { @@ -416,6 +412,38 @@ private function makeMigrationInstance(string $class): object return $this->injector->make($class); } + /** + * Returns the migration paths with namespaces if they are specified. + * + * @return array + */ + private function findSourcePaths(): array + { + $paths = []; + + foreach ($this->sourcePaths as $path) { + $paths[] = [$path, '']; + } + + foreach ($this->sourceNamespaces as $namespace) { + $paths[] = [$this->getNamespacePath($namespace), $namespace]; + } + + if ($paths !== []) { + return $paths; + } + + if ($this->newMigrationPath !== '') { + return [[$this->newMigrationPath, '']]; + } + + if ($this->newMigrationNamespace !== '') { + return [[$this->getNamespacePath($this->newMigrationNamespace), $this->newMigrationNamespace]]; + } + + return []; + } + /** * Returns the file path matching the give namespace. * diff --git a/tests/Common/Command/AbstractUpdateCommandTest.php b/tests/Common/Command/AbstractUpdateCommandTest.php index 46226f72..e7e1c61f 100644 --- a/tests/Common/Command/AbstractUpdateCommandTest.php +++ b/tests/Common/Command/AbstractUpdateCommandTest.php @@ -274,18 +274,56 @@ public function testWithoutSourcePath(): void $exitCode = $command->execute([]); $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); + $this->assertSame(Command::SUCCESS, $exitCode); + $this->assertStringContainsString('No new migrations found.', $output); + $this->assertStringContainsString('[OK] Your system is up-to-date.', $output); + } + + public function testWithoutSourceNamespaces(): void + { + MigrationHelper::useMigrationsNamespace($this->container); + + $this->container->get(MigrationService::class)->setSourceNamespaces([]); + + $command = $this->createCommand($this->container); + $command->setInputs(['yes']); + + $exitCode = $command->execute([]); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); + + $this->assertSame(Command::SUCCESS, $exitCode); + $this->assertStringContainsString('No new migrations found.', $output); + $this->assertStringContainsString('[OK] Your system is up-to-date.', $output); + } + + public function testWithoutMigrationPaths() + { + MigrationHelper::useMigrationsPath($this->container); + + $migration = $this->container->get(MigrationService::class); + $migration->setSourcePaths([]); + $migration->setNewMigrationPath(''); + + $command = $this->createCommand($this->container); + $command->setInputs(['yes']); + + $exitCode = $command->execute([]); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); + $this->assertSame(Command::INVALID, $exitCode); - $this->assertStringContainsStringCollapsingSpaces( - 'At least one of `sourceNamespaces` or `sourcePaths` should be specified.', + $this->assertStringContainsString( + 'At least one of `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace` or `newMigrationPath` should be specified.', $output, ); } - public function testWithoutSourceNamespaces(): void + public function testWithoutMigrationNamespaces(): void { MigrationHelper::useMigrationsNamespace($this->container); - $this->container->get(MigrationService::class)->setSourceNamespaces([]); + $migration = $this->container->get(MigrationService::class); + $migration->setSourceNamespaces([]); + $migration->setNewMigrationNamespace(''); $command = $this->createCommand($this->container); $command->setInputs(['yes']); @@ -294,8 +332,8 @@ public function testWithoutSourceNamespaces(): void $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); - $this->assertStringContainsStringCollapsingSpaces( - 'At least one of `sourceNamespaces` or `sourcePaths` should be specified.', + $this->assertStringContainsString( + 'At least one of `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace` or `newMigrationPath` should be specified.', $output, ); } From 6130a955ce3312d7d67d0621766905d7932ffc67 Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Fri, 20 Mar 2026 18:36:57 +0700 Subject: [PATCH 2/9] Apply suggestion [skip ci] Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/Common/Command/AbstractUpdateCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Common/Command/AbstractUpdateCommandTest.php b/tests/Common/Command/AbstractUpdateCommandTest.php index e7e1c61f..444ae9c9 100644 --- a/tests/Common/Command/AbstractUpdateCommandTest.php +++ b/tests/Common/Command/AbstractUpdateCommandTest.php @@ -296,7 +296,7 @@ public function testWithoutSourceNamespaces(): void $this->assertStringContainsString('[OK] Your system is up-to-date.', $output); } - public function testWithoutMigrationPaths() + public function testWithoutMigrationPaths(): void { MigrationHelper::useMigrationsPath($this->container); From 70b5e203d653e8fbdecc03855ea87bc195f63d3e Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sun, 3 May 2026 19:04:46 +0700 Subject: [PATCH 3/9] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae6032ea..0959a571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Enh #322, #330: Improve output of `migrate:up`, `migrate:down`, `migrate:redo`, `migrate:new`, `migrate:history`, and `migrate:create` commands: remove redundant messages, replace `>>>` with cleaner output, and move "Database connection" info to the top (@samdark, @vjik) +- Enh #333: Use `newMigrationPath` and `newMigrationNamespace` if `sourceNamespaces` and `sourcePaths` are not specified (@Tigrov) ## 2.0.1 December 20, 2025 From 2986f5d8de98d02e4478e391db55c3ed4bec519a Mon Sep 17 00:00:00 2001 From: Tigrov Date: Mon, 4 May 2026 11:31:01 +0700 Subject: [PATCH 4/9] Update --- src/Service/MigrationService.php | 34 ++-- .../Service/AbstractMigrationServiceTest.php | 166 ++++++++++++++++++ 2 files changed, 180 insertions(+), 20 deletions(-) diff --git a/src/Service/MigrationService.php b/src/Service/MigrationService.php index 3e3d1983..018e909c 100644 --- a/src/Service/MigrationService.php +++ b/src/Service/MigrationService.php @@ -128,12 +128,10 @@ public function getNewMigrations(): array $applied[trim($class, '\\')] = true; } - $migrationPaths = $this->findSourcePaths(); - $migrations = []; - foreach ($migrationPaths as $item) { - [$sourcePath, $namespace] = $item; + $migrationPaths = $this->findSourcePaths(); + foreach ($migrationPaths as [$sourcePath, $namespace]) { if (!is_dir($sourcePath)) { continue; } @@ -163,8 +161,8 @@ public function getNewMigrations(): array } closedir($handle); } - ksort($migrations); + ksort($migrations); return array_values($migrations); } @@ -421,27 +419,23 @@ private function findSourcePaths(): array { $paths = []; - foreach ($this->sourcePaths as $path) { - $paths[] = [$path, '']; - } - - foreach ($this->sourceNamespaces as $namespace) { - $paths[] = [$this->getNamespacePath($namespace), $namespace]; - } - - if ($paths !== []) { - return $paths; + if ($this->newMigrationPath !== '') { + $paths = [[$this->newMigrationPath, '']]; + } elseif ($this->newMigrationNamespace !== '') { + $newMigrationPath = $this->getNamespacePath($this->newMigrationNamespace); + $paths = [[$newMigrationPath, $this->newMigrationNamespace]]; } - if ($this->newMigrationPath !== '') { - return [[$this->newMigrationPath, '']]; + foreach ($this->sourcePaths as $sourcePaths) { + $paths[] = [$sourcePaths, '']; } - if ($this->newMigrationNamespace !== '') { - return [[$this->getNamespacePath($this->newMigrationNamespace), $this->newMigrationNamespace]]; + foreach ($this->sourceNamespaces as $namespace) { + $sourcePaths = $this->getNamespacePath($namespace); + $paths[] = [$sourcePaths, $namespace]; } - return []; + return $paths; } /** diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index 80a8074d..91235f1f 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Db\Migration\Tests\Common\Service; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use ReflectionMethod; @@ -57,6 +58,171 @@ public function testGetNewMigrationsWithNotExistNamespace(): void $this->assertSame([$className], $migrations); } + public static function getNewMigrationsDataProvider(): array + { + return [ + 'empty' => [ + 'expected' => [], + ], + 'non exists newMigrationNamespace' => [ + 'expected' => [], + 'newMigrationNamespace' => 'Yiisoft\Db\Migration\TestsRuntime\NotExists', + ], + 'non exists newMigrationPath' => [ + 'expected' => [], + 'newMigrationNamespace' => '', + 'newMigrationPath' => dirname(__DIR__, 2) . '/non-exists-directory', + ], + 'non exists sourceNamespaces' => [ + 'expected' => [], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => ['Yiisoft\Db\Migration\TestsRuntime\NotExists'], + ], + 'non exists sourcePaths' => [ + 'expected' => [], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => [], + 'sourcePaths' => [dirname(__DIR__, 2) . '/non-exists-directory'], + ], + 'with newMigrationNamespace' => [ + 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], + 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', + ], + 'with newMigrationPath' => [ + 'expected' => ['M231108183919Empty'], + 'newMigrationNamespace' => '', + 'newMigrationPath' => dirname(__DIR__, 2) . '/Support/MigrationsExtra', + ], + 'with sourceNamespaces with different paths' => [ + 'expected' => [ + 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231015155500ExecuteSql', + 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231017150317EmptyDown', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122400ChangeDbPrefixUp', + 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122500ChangeDbPrefixDown', + ], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => [ + 'Yiisoft\Db\Migration\Tests\ForTest\Migrations', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', + ], + ], + 'with different sourceNamespaces with the same path' => [ + 'expected' => [ + 'Yiisoft\Db\Migration\Tests\ForTest\MigrationsExtra\M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + ], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => [ + 'Yiisoft\Db\Migration\Tests\ForTest\MigrationsExtra', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', + ], + ], + 'with sourcePaths with different paths' => [ + 'expected' => [ + 'M231108183919Empty', + 'M231108183919Empty2', + ], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => [], + 'sourcePaths' => [ + dirname(__DIR__, 2) . '/Support/MigrationsExtra', + dirname(__DIR__, 2) . '/Support/MigrationsExtra2', + ], + ], + 'with sourceNamespaces and sourcePaths with the same path' => [ + 'expected' => [ + 'M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + ], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], + 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra'], + ], + 'with sourceNamespaces and sourcePaths with different paths' => [ + 'expected' => [ + 'M231108183919Empty2', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + ], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], + 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra2'], + ], + 'with newMigrationNamespace and sourceNamespaces with the same path' => [ + 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], + 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', + 'newMigrationPath' => '', + 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], + ], + 'with newMigrationPath and sourcePaths with the same path' => [ + 'expected' => ['M231108183919Empty'], + 'newMigrationNamespace' => '', + 'newMigrationPath' => dirname(__DIR__, 2) . '/Support/MigrationsExtra', + 'sourceNamespaces' => [], + 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra'], + ], + 'with newMigrationNamespace and sourcePaths with the same path' => [ + 'expected' => [ + 'M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + ], + 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', + 'newMigrationPath' => '', + 'sourceNamespaces' => [], + 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra'], + ], + 'with newMigrationNamespace and sourceNamespaces with different paths' => [ + 'expected' => [ + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', + ], + 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', + 'newMigrationPath' => '', + 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\Migrations'], + ], + 'with newMigrationPath and sourceNamespaces with different paths' => [ + 'expected' => [ + 'M231108183919Empty2', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + ], + 'newMigrationNamespace' => '', + 'newMigrationPath' => dirname(__DIR__, 2) . '/Support/MigrationsExtra2', + 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], + ], + ]; + } + + #[DataProvider('getNewMigrationsDataProvider')] + public function testGetNewMigrations( + array $expected, + string $newMigrationNamespace = '', + string $newMigrationPath = '', + array $sourceNamespaces = [], + array $sourcePaths = [], + ): void { + MigrationHelper::useMigrationsNamespace($this->container); + + $service = $this->container->get(MigrationService::class); + $service->setNewMigrationNamespace($newMigrationNamespace); + $service->setNewMigrationPath($newMigrationPath); + $service->setSourceNamespaces($sourceNamespaces); + $service->setSourcePaths($sourcePaths); + + $migrations = $service->getNewMigrations(); + + $this->assertSame($expected, $migrations); + } + public function testGetNamespacesFromPathForNoHavingNamespacePath(): void { $migrationService = $this->container->get(MigrationService::class); From c45dd010883a90a23bfe32544000d544a23548d1 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Mon, 4 May 2026 11:53:13 +0700 Subject: [PATCH 5/9] Update doc --- docs/guide/en/usage-standalone.md | 3 +-- docs/guide/en/usage-with-yii-console.md | 3 +-- docs/guide/pt-BR/usage-standalone.md | 4 ++-- docs/guide/pt-BR/usage-with-yii-console.md | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/guide/en/usage-standalone.md b/docs/guide/en/usage-standalone.md index 8e683ee7..b4967334 100644 --- a/docs/guide/en/usage-standalone.md +++ b/docs/guide/en/usage-standalone.md @@ -47,8 +47,7 @@ $migrationService->setNewMigrationPath(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR ``` > [!NOTE] -> If `sourceNamespaces` and `sourcePaths` are not specified, `newMigrationNamespace` or `newMigrationPath` will be used -> to find migrations. +> `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace`, and `newMigrationPath` will be used to find migrations. Then initialize the command for using without CLI. For example, for applying migrations it will be `UpdateCommand`: diff --git a/docs/guide/en/usage-with-yii-console.md b/docs/guide/en/usage-with-yii-console.md index de282081..9394fdd0 100644 --- a/docs/guide/en/usage-with-yii-console.md +++ b/docs/guide/en/usage-with-yii-console.md @@ -34,8 +34,7 @@ Add to `config/console/params.php`: ``` > [!NOTE] -> If `sourceNamespaces` and `sourcePaths` are not specified, `newMigrationNamespace` or `newMigrationPath` will be used -> to find migrations. +> `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace`, and `newMigrationPath` will be used to find migrations. Execute `composer du` in console to rebuild the configuration. diff --git a/docs/guide/pt-BR/usage-standalone.md b/docs/guide/pt-BR/usage-standalone.md index 12218499..e97953d1 100644 --- a/docs/guide/pt-BR/usage-standalone.md +++ b/docs/guide/pt-BR/usage-standalone.md @@ -47,8 +47,8 @@ $migrationService->setNewMigrationPath(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR ``` > [!NOTE] -> Se `sourceNamespaces` e `sourcePaths` não forem especificados, `newMigrationNamespace` ou `newMigrationPath` serão -> usados para encontrar as migrações. +> `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace` e `newMigrationPath` serão usados para encontrar +> as migrações. Em seguida, inicialize o comando para usar sem CLI. Por exemplo, para aplicar migrações será `UpdateCommand`: diff --git a/docs/guide/pt-BR/usage-with-yii-console.md b/docs/guide/pt-BR/usage-with-yii-console.md index 90f3186a..1fe3688b 100644 --- a/docs/guide/pt-BR/usage-with-yii-console.md +++ b/docs/guide/pt-BR/usage-with-yii-console.md @@ -34,8 +34,8 @@ Adicione em `config/console/params.php`: ``` > [!NOTE] -> Se `sourceNamespaces` e `sourcePaths` não forem especificados, `newMigrationNamespace` ou `newMigrationPath` serão -> usados para encontrar as migrações. +> `sourceNamespaces`, `sourcePaths`, `newMigrationNamespace` e `newMigrationPath` serão usados para encontrar +> as migrações. Execute `composer du` no console para reconstruir a configuração. From 519318bc753774a928ee0f39808a5277046a6349 Mon Sep 17 00:00:00 2001 From: Tigrov <8563175+Tigrov@users.noreply.github.com> Date: Mon, 4 May 2026 07:39:41 +0000 Subject: [PATCH 6/9] Apply PHP CS Fixer and Rector changes (CI) --- .../Service/AbstractMigrationServiceTest.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index 91235f1f..6def6aa8 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -87,7 +87,7 @@ public static function getNewMigrationsDataProvider(): array 'sourcePaths' => [dirname(__DIR__, 2) . '/non-exists-directory'], ], 'with newMigrationNamespace' => [ - 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], + 'expected' => [\Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', ], 'with newMigrationPath' => [ @@ -99,7 +99,7 @@ public static function getNewMigrationsDataProvider(): array 'expected' => [ 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231015155500ExecuteSql', 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231017150317EmptyDown', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122400ChangeDbPrefixUp', 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122500ChangeDbPrefixDown', ], @@ -113,7 +113,7 @@ public static function getNewMigrationsDataProvider(): array 'with different sourceNamespaces with the same path' => [ 'expected' => [ 'Yiisoft\Db\Migration\Tests\ForTest\MigrationsExtra\M231108183919Empty', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -138,7 +138,7 @@ public static function getNewMigrationsDataProvider(): array 'with sourceNamespaces and sourcePaths with the same path' => [ 'expected' => [ 'M231108183919Empty', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -148,7 +148,7 @@ public static function getNewMigrationsDataProvider(): array 'with sourceNamespaces and sourcePaths with different paths' => [ 'expected' => [ 'M231108183919Empty2', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -156,7 +156,7 @@ public static function getNewMigrationsDataProvider(): array 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra2'], ], 'with newMigrationNamespace and sourceNamespaces with the same path' => [ - 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], + 'expected' => [\Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], @@ -171,7 +171,7 @@ public static function getNewMigrationsDataProvider(): array 'with newMigrationNamespace and sourcePaths with the same path' => [ 'expected' => [ 'M231108183919Empty', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, ], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', @@ -180,11 +180,11 @@ public static function getNewMigrationsDataProvider(): array ], 'with newMigrationNamespace and sourceNamespaces with different paths' => [ 'expected' => [ - 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', - 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', - 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', - 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', + \Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql::class, + \Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown::class, + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + \Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp::class, + \Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown::class, ], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', @@ -193,7 +193,7 @@ public static function getNewMigrationsDataProvider(): array 'with newMigrationPath and sourceNamespaces with different paths' => [ 'expected' => [ 'M231108183919Empty2', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, ], 'newMigrationNamespace' => '', 'newMigrationPath' => dirname(__DIR__, 2) . '/Support/MigrationsExtra2', From c35f24fd307a0432315a6de71748ce440155f224 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Mon, 4 May 2026 14:53:07 +0700 Subject: [PATCH 7/9] fix rector --- composer.json | 18 +++++----- rector.php | 2 ++ .../Service/AbstractMigrationServiceTest.php | 36 +++++++++---------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index ad7fda7d..16c29a96 100644 --- a/composer.json +++ b/composer.json @@ -37,16 +37,16 @@ "yiisoft/injector": "^1.2" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.3", - "friendsofphp/php-cs-fixer": "^3.89.2", - "phpunit/phpunit": "^10.5.45", - "rector/rector": "^2.0.10", + "bamarni/composer-bin-plugin": "^1.9.1", + "friendsofphp/php-cs-fixer": "^3.95.1", + "phpunit/phpunit": "^10.5.63", + "rector/rector": "^2.4.2", "yiisoft/db-sqlite": "^2.0", - "yiisoft/di": "^1.3", - "yiisoft/files": "^2.0", - "yiisoft/psr-dummy-provider": "^1.0", - "yiisoft/test-support": "^3.0.2", - "yiisoft/yii-console": "^2.3" + "yiisoft/di": "^1.4.1", + "yiisoft/files": "^2.1", + "yiisoft/psr-dummy-provider": "^1.0.2", + "yiisoft/test-support": "^3.2.0", + "yiisoft/yii-console": "^2.4.2" }, "autoload": { "psr-4": { diff --git a/rector.php b/rector.php index b324a6e9..36a1007e 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; +use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; @@ -21,5 +22,6 @@ NullToStrictStringFuncCallArgRector::class, ReadOnlyPropertyRector::class, RemoveExtraParametersRector::class => [__DIR__ . '/src/Service/Generate/PhpRenderer.php'], + StringClassNameToClassConstantRector::class => [__DIR__ . '/tests/Common/Service/AbstractMigrationServiceTest.php'], ]) ->withoutParallel(); diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index 6def6aa8..0abf908b 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -87,7 +87,7 @@ public static function getNewMigrationsDataProvider(): array 'sourcePaths' => [dirname(__DIR__, 2) . '/non-exists-directory'], ], 'with newMigrationNamespace' => [ - 'expected' => [\Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class], + 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', ], 'with newMigrationPath' => [ @@ -97,23 +97,23 @@ public static function getNewMigrationsDataProvider(): array ], 'with sourceNamespaces with different paths' => [ 'expected' => [ - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231015155500ExecuteSql', - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231017150317EmptyDown', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122400ChangeDbPrefixUp', - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122500ChangeDbPrefixDown', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', 'sourceNamespaces' => [ - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations', + 'Yiisoft\Db\Migration\Tests\Support\Migrations', 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', ], ], 'with different sourceNamespaces with the same path' => [ 'expected' => [ 'Yiisoft\Db\Migration\Tests\ForTest\MigrationsExtra\M231108183919Empty', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -138,7 +138,7 @@ public static function getNewMigrationsDataProvider(): array 'with sourceNamespaces and sourcePaths with the same path' => [ 'expected' => [ 'M231108183919Empty', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -148,7 +148,7 @@ public static function getNewMigrationsDataProvider(): array 'with sourceNamespaces and sourcePaths with different paths' => [ 'expected' => [ 'M231108183919Empty2', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -156,7 +156,7 @@ public static function getNewMigrationsDataProvider(): array 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra2'], ], 'with newMigrationNamespace and sourceNamespaces with the same path' => [ - 'expected' => [\Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class], + 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], @@ -171,7 +171,7 @@ public static function getNewMigrationsDataProvider(): array 'with newMigrationNamespace and sourcePaths with the same path' => [ 'expected' => [ 'M231108183919Empty', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', @@ -180,11 +180,11 @@ public static function getNewMigrationsDataProvider(): array ], 'with newMigrationNamespace and sourceNamespaces with different paths' => [ 'expected' => [ - \Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql::class, - \Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown::class, - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, - \Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp::class, - \Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown::class, + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', ], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', @@ -193,7 +193,7 @@ public static function getNewMigrationsDataProvider(): array 'with newMigrationPath and sourceNamespaces with different paths' => [ 'expected' => [ 'M231108183919Empty2', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => dirname(__DIR__, 2) . '/Support/MigrationsExtra2', From 204ad67f14fd042c89e53349f38630d3e842a9bf Mon Sep 17 00:00:00 2001 From: Tigrov Date: Mon, 4 May 2026 14:53:07 +0700 Subject: [PATCH 8/9] fix --- composer.json | 18 +++++----- rector.php | 2 ++ .../Service/AbstractMigrationServiceTest.php | 36 +++++++++---------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index ad7fda7d..16c29a96 100644 --- a/composer.json +++ b/composer.json @@ -37,16 +37,16 @@ "yiisoft/injector": "^1.2" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.3", - "friendsofphp/php-cs-fixer": "^3.89.2", - "phpunit/phpunit": "^10.5.45", - "rector/rector": "^2.0.10", + "bamarni/composer-bin-plugin": "^1.9.1", + "friendsofphp/php-cs-fixer": "^3.95.1", + "phpunit/phpunit": "^10.5.63", + "rector/rector": "^2.4.2", "yiisoft/db-sqlite": "^2.0", - "yiisoft/di": "^1.3", - "yiisoft/files": "^2.0", - "yiisoft/psr-dummy-provider": "^1.0", - "yiisoft/test-support": "^3.0.2", - "yiisoft/yii-console": "^2.3" + "yiisoft/di": "^1.4.1", + "yiisoft/files": "^2.1", + "yiisoft/psr-dummy-provider": "^1.0.2", + "yiisoft/test-support": "^3.2.0", + "yiisoft/yii-console": "^2.4.2" }, "autoload": { "psr-4": { diff --git a/rector.php b/rector.php index b324a6e9..36a1007e 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; +use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; @@ -21,5 +22,6 @@ NullToStrictStringFuncCallArgRector::class, ReadOnlyPropertyRector::class, RemoveExtraParametersRector::class => [__DIR__ . '/src/Service/Generate/PhpRenderer.php'], + StringClassNameToClassConstantRector::class => [__DIR__ . '/tests/Common/Service/AbstractMigrationServiceTest.php'], ]) ->withoutParallel(); diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index 6def6aa8..e2e53f88 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -87,7 +87,7 @@ public static function getNewMigrationsDataProvider(): array 'sourcePaths' => [dirname(__DIR__, 2) . '/non-exists-directory'], ], 'with newMigrationNamespace' => [ - 'expected' => [\Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class], + 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', ], 'with newMigrationPath' => [ @@ -97,23 +97,23 @@ public static function getNewMigrationsDataProvider(): array ], 'with sourceNamespaces with different paths' => [ 'expected' => [ - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231015155500ExecuteSql', - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M231017150317EmptyDown', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122400ChangeDbPrefixUp', - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations\M250312122500ChangeDbPrefixDown', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', 'sourceNamespaces' => [ - 'Yiisoft\Db\Migration\Tests\ForTest\Migrations', + 'Yiisoft\Db\Migration\Tests\Support\Migrations', 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', ], ], 'with different sourceNamespaces with the same path' => [ 'expected' => [ 'Yiisoft\Db\Migration\Tests\ForTest\MigrationsExtra\M231108183919Empty', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -138,7 +138,7 @@ public static function getNewMigrationsDataProvider(): array 'with sourceNamespaces and sourcePaths with the same path' => [ 'expected' => [ 'M231108183919Empty', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -148,7 +148,7 @@ public static function getNewMigrationsDataProvider(): array 'with sourceNamespaces and sourcePaths with different paths' => [ 'expected' => [ 'M231108183919Empty2', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => '', @@ -156,7 +156,7 @@ public static function getNewMigrationsDataProvider(): array 'sourcePaths' => [dirname(__DIR__, 2) . '/Support/MigrationsExtra2'], ], 'with newMigrationNamespace and sourceNamespaces with the same path' => [ - 'expected' => [\Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class], + 'expected' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty'], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', 'sourceNamespaces' => ['Yiisoft\Db\Migration\Tests\Support\MigrationsExtra'], @@ -171,7 +171,7 @@ public static function getNewMigrationsDataProvider(): array 'with newMigrationNamespace and sourcePaths with the same path' => [ 'expected' => [ 'M231108183919Empty', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', @@ -180,11 +180,11 @@ public static function getNewMigrationsDataProvider(): array ], 'with newMigrationNamespace and sourceNamespaces with different paths' => [ 'expected' => [ - \Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql::class, - \Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown::class, - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, - \Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp::class, - \Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown::class, + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', + 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', ], 'newMigrationNamespace' => 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra', 'newMigrationPath' => '', @@ -193,7 +193,7 @@ public static function getNewMigrationsDataProvider(): array 'with newMigrationPath and sourceNamespaces with different paths' => [ 'expected' => [ 'M231108183919Empty2', - \Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class, + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', ], 'newMigrationNamespace' => '', 'newMigrationPath' => dirname(__DIR__, 2) . '/Support/MigrationsExtra2', From dcd59b2cbe514ce49c2ed004608611a04c6ace6b Mon Sep 17 00:00:00 2001 From: Tigrov Date: Mon, 4 May 2026 15:03:07 +0700 Subject: [PATCH 9/9] fix --- tests/Common/Service/AbstractMigrationServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index 0abf908b..e2e53f88 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -99,7 +99,7 @@ public static function getNewMigrationsDataProvider(): array 'expected' => [ 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231015155500ExecuteSql', 'Yiisoft\Db\Migration\Tests\Support\Migrations\M231017150317EmptyDown', - 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty::class', + 'Yiisoft\Db\Migration\Tests\Support\MigrationsExtra\M231108183919Empty', 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122400ChangeDbPrefixUp', 'Yiisoft\Db\Migration\Tests\Support\Migrations\M250312122500ChangeDbPrefixDown', ],