New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Add support for multiple --path to migrate:reset #18540

Merged
merged 2 commits into from Mar 29, 2017

Conversation

Projects
None yet
3 participants
@mingalevme
Contributor

mingalevme commented Mar 28, 2017

It's required for migrate:reset if you run migrations from different paths:

./artisan migrate
./artisan migrate --path database/migrations/foodir1
./artisan migrate --path database/migrations/bardir2

./artisan migrate:reset will fail with something like this:

[ErrorException]
Undefined index: 2016_10_11_153917_some_migration_from_foodir1_or_bardir2

At the same time next code will work (with mine changes):

./artisan migrate:reset --path database/migrations --path database/migrations/foodir1 --path database/migrations/bardir2

@tillkruss tillkruss changed the title from migrate:reset: added support for multiple --path option to [5.4] Add support for multiple --path to migrate:reset Mar 28, 2017

@fitztrev

This comment has been minimized.

Show comment
Hide comment
@fitztrev

fitztrev Mar 29, 2017

Contributor

Similar #7884

Contributor

fitztrev commented Mar 29, 2017

Similar #7884

@mingalevme

This comment has been minimized.

Show comment
Hide comment
@mingalevme

mingalevme Mar 29, 2017

Contributor

The behavior of migrate:reset was changed since 5.2 (as least for Lumen), I have an application built on Lumen 5.2 and the next code works for 5.2:

Artisan::call('migrate', [
    '-vvv' => true,
]);
Artisan::call('migrate', [
    '--path' => 'database/migrations/foobarmodule',
    '-vvv' => true,
]);
...
Artisan::call('migrate:reset');

The above code successfully runs all migrations from default migrations dir (/database/migrations) and custom dir (/database/migrations/foobarmodule) and then successfully resets ALL migrations back, this is relevant for version 5.2. But some time ago I upgraded Lumen to 5.4 and the above code fails while resetting migrations:

./artisan migrate:reset
[ErrorException]
Undefined index: YYYY_MM_DD_TTTTTT_some_migration_from_subdir_foobarmodule

The --path option does not solve the problem:

./artisan migrate:reset --path database/migrations/foobarmodule
[ErrorException]
Undefined index: YYYY_MM_DD_TTTTTT_some_migration_from_base_migrations_dir

The full stacktrace:

vagrant@mingalevme:/www/projects/mfeed> ./artisan migrate:reset
[2017-03-28 16:52:26] lumen.ERROR: ErrorException: Undefined index: 2016_10_11_153917_rian_add_rian_application in /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php:245
Stack trace:
#0 /www/projects/mfeed/vendor/sentry/sentry/lib/Raven/Breadcrumbs/ErrorHandler.php(36): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(8, 'Undefined index...', '/www/projects/m...', 245, Array)
#1 /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php(245): Raven_Breadcrumbs_ErrorHandler->handleError(8, 'Undefined index...', '/www/projects/m...', 245, Array)
#2 /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php(299): Illuminate\Database\Migrations\Migrator->rollbackMigrations(Array, Array, Array)
#3 /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php(277): Illuminate\Database\Migrations\Migrator->resetMigrations(Array, Array, false)
#4 /www/projects/mfeed/vendor/illuminate/database/Console/Migrations/ResetCommand.php(68): Illuminate\Database\Migrations\Migrator->reset(Array, false)
#5 [internal function]: Illuminate\Database\Console\Migrations\ResetCommand->fire()
#6 /www/projects/mfeed/vendor/illuminate/container/BoundMethod.php(28): call_user_func_array(Array, Array)
#7 /www/projects/mfeed/vendor/illuminate/support/helpers.php(912): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /www/projects/mfeed/vendor/illuminate/container/BoundMethod.php(86): value(Object(Closure))
#9 /www/projects/mfeed/vendor/illuminate/container/BoundMethod.php(30): Illuminate\Container\BoundMethod::callBoundMethod(Object(App\Helpers\Laravel\Lumen\Application), Array, Object(Closure))
#10 /www/projects/mfeed/vendor/illuminate/container/Container.php(524): Illuminate\Container\BoundMethod::call(Object(App\Helpers\Laravel\Lumen\Application), Array, Array, NULL)
#11 /www/projects/mfeed/app/Helpers/Laravel/Lumen/Application.php(67): Illuminate\Container\Container->call(Array, Array, NULL)
#12 /www/projects/mfeed/vendor/illuminate/console/Command.php(182): App\Helpers\Laravel\Lumen\Application->call(Array)
#13 /www/projects/mfeed/vendor/symfony/console/Command/Command.php(265): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#14 /www/projects/mfeed/vendor/illuminate/console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#15 /www/projects/mfeed/vendor/symfony/console/Application.php(826): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /www/projects/mfeed/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\ResetCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /www/projects/mfeed/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /www/projects/mfeed/vendor/laravel/lumen-framework/src/Console/Kernel.php(84): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /www/projects/mfeed/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 {main}
Contributor

mingalevme commented Mar 29, 2017

The behavior of migrate:reset was changed since 5.2 (as least for Lumen), I have an application built on Lumen 5.2 and the next code works for 5.2:

Artisan::call('migrate', [
    '-vvv' => true,
]);
Artisan::call('migrate', [
    '--path' => 'database/migrations/foobarmodule',
    '-vvv' => true,
]);
...
Artisan::call('migrate:reset');

The above code successfully runs all migrations from default migrations dir (/database/migrations) and custom dir (/database/migrations/foobarmodule) and then successfully resets ALL migrations back, this is relevant for version 5.2. But some time ago I upgraded Lumen to 5.4 and the above code fails while resetting migrations:

./artisan migrate:reset
[ErrorException]
Undefined index: YYYY_MM_DD_TTTTTT_some_migration_from_subdir_foobarmodule

The --path option does not solve the problem:

./artisan migrate:reset --path database/migrations/foobarmodule
[ErrorException]
Undefined index: YYYY_MM_DD_TTTTTT_some_migration_from_base_migrations_dir

The full stacktrace:

vagrant@mingalevme:/www/projects/mfeed> ./artisan migrate:reset
[2017-03-28 16:52:26] lumen.ERROR: ErrorException: Undefined index: 2016_10_11_153917_rian_add_rian_application in /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php:245
Stack trace:
#0 /www/projects/mfeed/vendor/sentry/sentry/lib/Raven/Breadcrumbs/ErrorHandler.php(36): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(8, 'Undefined index...', '/www/projects/m...', 245, Array)
#1 /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php(245): Raven_Breadcrumbs_ErrorHandler->handleError(8, 'Undefined index...', '/www/projects/m...', 245, Array)
#2 /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php(299): Illuminate\Database\Migrations\Migrator->rollbackMigrations(Array, Array, Array)
#3 /www/projects/mfeed/vendor/illuminate/database/Migrations/Migrator.php(277): Illuminate\Database\Migrations\Migrator->resetMigrations(Array, Array, false)
#4 /www/projects/mfeed/vendor/illuminate/database/Console/Migrations/ResetCommand.php(68): Illuminate\Database\Migrations\Migrator->reset(Array, false)
#5 [internal function]: Illuminate\Database\Console\Migrations\ResetCommand->fire()
#6 /www/projects/mfeed/vendor/illuminate/container/BoundMethod.php(28): call_user_func_array(Array, Array)
#7 /www/projects/mfeed/vendor/illuminate/support/helpers.php(912): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /www/projects/mfeed/vendor/illuminate/container/BoundMethod.php(86): value(Object(Closure))
#9 /www/projects/mfeed/vendor/illuminate/container/BoundMethod.php(30): Illuminate\Container\BoundMethod::callBoundMethod(Object(App\Helpers\Laravel\Lumen\Application), Array, Object(Closure))
#10 /www/projects/mfeed/vendor/illuminate/container/Container.php(524): Illuminate\Container\BoundMethod::call(Object(App\Helpers\Laravel\Lumen\Application), Array, Array, NULL)
#11 /www/projects/mfeed/app/Helpers/Laravel/Lumen/Application.php(67): Illuminate\Container\Container->call(Array, Array, NULL)
#12 /www/projects/mfeed/vendor/illuminate/console/Command.php(182): App\Helpers\Laravel\Lumen\Application->call(Array)
#13 /www/projects/mfeed/vendor/symfony/console/Command/Command.php(265): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#14 /www/projects/mfeed/vendor/illuminate/console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#15 /www/projects/mfeed/vendor/symfony/console/Application.php(826): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /www/projects/mfeed/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\ResetCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /www/projects/mfeed/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /www/projects/mfeed/vendor/laravel/lumen-framework/src/Console/Kernel.php(84): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /www/projects/mfeed/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 {main}
migrate:reset: --path may be a single string
Fixed situation when `migrate:reset` is run from application:
```
Artisan::call('migrate:reset', [
    '--path' => 'database/migrations',
]);
```

@taylorotwell taylorotwell merged commit 88f369a into laravel:5.4 Mar 29, 2017

2 checks passed

continuous-integration/styleci/pr The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment