rollBackLastMigration() and rollBackAllMigrations() fails when migration files are not loaded
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)
-
reporter -
reporter Unit test for ConnectionResolverTrait, see
#1→ <<cset ce82416aecb9>>
-
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...
-
reporter - changed status to resolved
- Log in to comment
Storing an internal list of loaded migration files and the directory they are located in - @see issue
#1→ <<cset 6a400f0e1675>>