Skip to content

improve error message if a migration contains the old base migration class#1059

Merged
markstory merged 1 commit into5.xfrom
5.x-better-error
Mar 27, 2026
Merged

improve error message if a migration contains the old base migration class#1059
markstory merged 1 commit into5.xfrom
5.x-better-error

Conversation

@LordSimal
Copy link
Copy Markdown
Contributor

@LordSimal LordSimal commented Mar 27, 2026

Fixes #1058

Now PHPUnit fails with this error:

PHPUnit 13.0.5 by Sebastian Bergmann and contributors.

Error in bootstrap script: RuntimeException:
Could not apply migrations for {"connection":"test"}

Migrations failed to apply with message:

Migration file `/Users/kevin/Documents/sunlime/alfred/config/Migrations/20260311200000_Initial.php` uses the legacy `Migrations\AbstractMigration` class, which is not available in this version. Update the migration to extend `Migrations\BaseMigration`.

If you are using the `skip` option and running multiple sets of migrations on the same connection, you can't skip tables managed by CakePHP in the connection.
#0 /Users/kevin/Documents/sunlime/alfred/tests/bootstrap.php(62): Migrations\TestSuite\Migrator->runMany(Array)
#1 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/src/TextUI/Configuration/BootstrapLoader.php(61): include_once('/Users/kevin/Do...')
#2 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/src/TextUI/Configuration/BootstrapLoader.php(36): PHPUnit\TextUI\Configuration\BootstrapLoader->load('/Users/kevin/Do...')
#3 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/src/TextUI/Application.php(132): PHPUnit\TextUI\Configuration\BootstrapLoader->handle(Object(PHPUnit\TextUI\Configuration\Configuration))
#4 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run(Array)
#5 /Users/kevin/Documents/sunlime/alfred/vendor/bin/phpunit(122): include('/Users/kevin/Do...')
#6 {main}

Previous error: RuntimeException:
Migration file `/Users/kevin/Documents/sunlime/alfred/config/Migrations/20260311200000_Initial.php` uses the legacy `Migrations\AbstractMigration` class, which is not available in this version. Update the migration to extend `Migrations\BaseMigration`.
#0 /Users/kevin/Documents/sunlime/alfred/vendor/cakephp/migrations/src/Migration/Manager.php(978): Migrations\Migration\Manager->checkMigrationClass('/Users/kevin/Do...')
#1 /Users/kevin/Documents/sunlime/alfred/vendor/cakephp/migrations/src/Migration/Manager.php(452): Migrations\Migration\Manager->getMigrations()
#2 /Users/kevin/Documents/sunlime/alfred/vendor/cakephp/migrations/src/Migration/BuiltinBackend.php(96): Migrations\Migration\Manager->migrate(NULL)
#3 /Users/kevin/Documents/sunlime/alfred/vendor/cakephp/migrations/src/Migrations.php(114): Migrations\Migration\BuiltinBackend->migrate(Array)
#4 /Users/kevin/Documents/sunlime/alfred/vendor/cakephp/migrations/src/TestSuite/Migrator.php(116): Migrations\Migrations->migrate(Array)
#5 /Users/kevin/Documents/sunlime/alfred/tests/bootstrap.php(62): Migrations\TestSuite\Migrator->runMany(Array)
#6 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/src/TextUI/Configuration/BootstrapLoader.php(61): include_once('/Users/kevin/Do...')
#7 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/src/TextUI/Configuration/BootstrapLoader.php(36): PHPUnit\TextUI\Configuration\BootstrapLoader->load('/Users/kevin/Do...')
#8 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/src/TextUI/Application.php(132): PHPUnit\TextUI\Configuration\BootstrapLoader->handle(Object(PHPUnit\TextUI\Configuration\Configuration))
#9 /Users/kevin/Documents/sunlime/alfred/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run(Array)
#10 /Users/kevin/Documents/sunlime/alfred/vendor/bin/phpunit(122): include('/Users/kevin/Do...')
#11 {main}

@markstory markstory merged commit e485847 into 5.x Mar 27, 2026
14 checks passed
@markstory markstory deleted the 5.x-better-error branch March 27, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Class "Migrations\AbstractMigration" not found error does not point to migration which is broken

3 participants