Migrations Rollback/Reset getting failed for migrations from subfolder or custom path.
[ErrorException]
Undefined index: 2016_09_05_192848_create_userException trace:
() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:252
IlluminateFoundationBootstrapHandleExceptions->handleError() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:252
IlluminateDatabaseMigrationsMigrator->reset() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php:68
IlluminateDatabaseConsoleMigrationsResetCommand->fire() at n/a:n/a
call_user_func_array() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
IlluminateContainerContainer->call() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
IlluminateConsoleCommand->execute() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/symfony/console/Command/Command.php:256
SymfonyComponentConsoleCommandCommand->run() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
IlluminateConsoleCommand->run() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/symfony/console/Application.php:818
SymfonyComponentConsoleApplication->doRunCommand() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/symfony/console/Application.php:186
SymfonyComponentConsoleApplication->doRun() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/symfony/console/Application.php:117
SymfonyComponentConsoleApplication->run() at /var/www/smarttrainerlms/app.smarttrainerlms.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
IlluminateFoundationConsoleKernel->handle() at /var/www/smarttrainerlms/app.smarttrainerlms.com/artisan:35My Findings:
I see first parameter is path in Illiminate/Database/Migrations/Migrator.php reset function but it is not passed from console Illiminate/Database/Console/Migrations/RollbackCommand.php and not even accepted from user.
You need to add custom path to custom migrations folder through a service provider.
Use something like this in a service provider:
$this->loadMigrationsFrom(base_path('database/migrations/xyz'));
Since you're using paths you must define them in a service provider in order for the migrator to load the files in them.
using folders for migration table organization and testing. sorry if duplicate. spent an hour trying to figure this out / very simple solution.
had undefined index problem on migrate:reset. composer dump-autload, deleting migrations table, restarting vagrant, lots of other attempts all failed.
simple solution: php artisan migrate:rollback --path=/database/migrations/folder
pass the path parameter to the rollback method. that's the solution if composer dump-autoload doesn't work for you on rollback or reset due to undefined index error.
Most helpful comment
Use something like this in a service provider:
Since you're using paths you must define them in a service provider in order for the migrator to load the files in them.