diff --git a/src/Model/Migration/MigrationGroup.php b/src/Model/Migration/MigrationGroup.php index 77bd279..3b79ebd 100644 --- a/src/Model/Migration/MigrationGroup.php +++ b/src/Model/Migration/MigrationGroup.php @@ -159,14 +159,14 @@ public function getLastMigration(): ?MigrationStatus /** * 指定バージョンまでマイグレーションを実行する * - * @param string $id migration ID + * @param string|int $id migration ID * @return string * @throws \Exception */ - public function migrateTo(string $id): string + public function migrateTo($id): string { $manager = $this->getManager(); - $manager->migrate($this->getConfig()->getDefaultEnvironment(), $id); + $manager->migrate($this->getConfig()->getDefaultEnvironment(), (int)$id); return $this->output->fetch(); } diff --git a/tests/TestCase/Model/Migration/MigrationGroupTest.php b/tests/TestCase/Model/Migration/MigrationGroupTest.php index b3524ac..bc95234 100644 --- a/tests/TestCase/Model/Migration/MigrationGroupTest.php +++ b/tests/TestCase/Model/Migration/MigrationGroupTest.php @@ -62,7 +62,7 @@ public function testConstructApp(): void $this->assertRegExp('!^' . $configPathMatch . '/Migrations$!', $object->getConfig()->getMigrationPaths()[0]); $this->assertRegExp('!^' . $configPathMatch . '/Seeds$!', $object->getConfig()->getSeedPaths()[0]); $environment = $object->getConfig()->getEnvironment('default'); - $this->assertSame('phinxlog', $environment['default_migration_table']); + $this->assertSame('phinxlog', $environment['migration_table'] ?? $environment['default_migration_table']); } /** @@ -82,7 +82,7 @@ public function testConstructPlugin(): void Plugin::configPath('Elastic/MigrationManager') . 'Seeds', ], $object->getConfig()->getSeedPaths()); $environment = $object->getConfig()->getEnvironment('default'); - $this->assertSame('elastic_migration_manager_phinxlog', $environment['default_migration_table']); + $this->assertSame('elastic_migration_manager_phinxlog', $environment['migration_table'] ?? $environment['default_migration_table']); } /** @@ -96,7 +96,7 @@ public function testGetMigrations(): void $first = $migrations->first(); $this->assertInstanceOf(MigrationStatus::class, $first); $this->assertSame('down', $first->status); - $this->assertSame('20191008091658', $first->id); + $this->assertSame('20191008091658', (string)$first->id); $this->assertSame('InitForTest', $first->name); } @@ -109,7 +109,7 @@ public function testGetLastMigration(): void $this->assertInstanceOf(MigrationStatus::class, $last); $this->assertSame('down', $last->status); - $this->assertSame('20191008091959', $last->id); + $this->assertSame('20191008091959', (string)$last->id); $this->assertSame('ThirdMigrationForTest', $last->name); }