rollBackLastMigration() and rollBackAllMigrations() fails when migration files are not loaded

Issue #1 resolved
Alin Eugen Deac repo owner created an issue

While the runMigrationList() does handle file loading automatically (almost just like Laravel's migrator), the problem is that whatever has been migrated from a package, cannot me rolled back, if those migration files are not loaded!

Sadly, relying on composer's autoload -> classmap does not handle recursive file loading.

Current workaround

Manually specify all the migration files via composer's autoload, either as files or classmap. This way, rolling back shouldn't be any issue.

Possible future solution

Create an additional migrations_helper table, which can store information about the full path of the executed migrations. Doing so, we do not touch Laravel's migrations table.

Once a migration has been executed, we ensure to store the full paths into that given table and load the files, when / if roll back is invoked.

Yet, the problem might still remain... What if the developer uses this package to run package migrations, but uses the default Laravel migration:rollback or migration:reset command to roll back?

Another possible future solution

The migration repository automatically stores the full path of the executed migrations. Thus, a new concrete implementation of the \Illuminate\Database\Migrations\MigrationRepositoryInterface could achieve such. But... The Migrator might also have to be modified for this purpose.

Comments (4)

  1. Alin Eugen Deac reporter

    This issue is actually very easily resolved - one has but to make sure that the migrations have been class-mapped via composer's autoload...

  2. Log in to comment