Framework: [5.5] artisan migrate:fresh with --seed and --no-interact does not pass --no-interact on to seeders

Created on 8 Aug 2019  路  5Comments  路  Source: laravel/framework

  • Laravel Version: 5.5.46
  • PHP Version: 7.2.19
  • Database Driver & Version: libmysql - mysqlnd 5.0.12-dev - 20150407 (MariaDB 10.3.11)

Description:

When running php artisan migrate:fresh --seed --no-interact, the --no-interact option is not passed along when running the DatabaseSeeder, thus I end up being asked things from my interactive seeders instead of them using the defaults.

Running php artisan db:seed --no-interact works well. db:seed just runs DatabaseSeeder that again just has a bunch of $this->call('SeederName');s, but all of those seeder get the --no-interact option applied.

Wouldn't it make sense for this to be the case when running migrate:fresh --seed --no-interact as well?

I have tested this in Laravel 5.8.31 as well, and this does not happen there, so is has likely been fixed at some point, but not backported to 5.5?

Edit: this is also related to #27009 and #27012.

Steps To Reproduce:

  1. Create a seeder that asks a question, using $this->command->ask() - and provide a default answer.
  2. Add your seeder to database/seeds/DatabaseSeeder.php
  3. Run php artisan db:seed -n and see that it is seeded without the question appearing, defaulting to the correct value
  4. Run php artisan migrate:fresh --seed -n and see that the migrations are re-run successfully, but when starting to seed it will ask your quesiton, halting the process if it is scripted.

Workaround

php artisan migrate:fresh && php artisan db:seed -n

bug

Most helpful comment

Merged.

All 5 comments

It seems this is the commit that fixed this in more recent versions: https://github.com/laravel/framework/commit/01374db3f8dfce9995370fa12a487ce10d7a4d7c

Workaround

php artisan migrate:fresh && php artisan db:seed -n

Thank you for this workaround :+1:

@carestad feel free to send in a PR to the 5.5 branch. Please be aware that support for 5.5 ends this month so make sure you upgrade soon.

@carestad feel free to send in a PR to the 5.5 branch. Please be aware that support for 5.5 ends this month so make sure you upgrade soon.

Done! #29478

Basically a cherry-picking of #27012.

Merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lzp819739483 picture lzp819739483  路  3Comments

gabriellimo picture gabriellimo  路  3Comments

digirew picture digirew  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

kerbylav picture kerbylav  路  3Comments