Framework: artisan migrate:refresh in production environment

Created on 18 Jun 2014  Â·  8Comments  Â·  Source: laravel/framework

I have just noticed there is a new warning message in 4.2 when using migrate in production environment. "Do you really wish to run this command?" is displayed. Problem is it's not displayed once, but multiple times (3 to be exact for migrate:refresh). I can theoretically suppress this message using -n option. The problem is it's working for the first message appearance only.

I assume this is not correct behaviour.

This is what I see:

[@uat]# php artisan migrate:refresh -n
**************************************
*     Application In Production!     *
**************************************

**************************************
*     Application In Production!     *
**************************************

Do you really wish to run this command? y
Rolled back: 2014_05_09_093438_create_failed_jobs_table
Rolled back: 2014_02_12_172015_create_baseline_tables
Nothing to rollback.
**************************************
*     Application In Production!     *
**************************************

Do you really wish to run this command? y
Migrated: 2014_02_12_172015_create_baseline_tables
Migrated: 2014_05_09_093438_create_failed_jobs_table

Most helpful comment

You can use the --force command to force the migration if you wish. I'll look into suppressing the message if it's already been displayed.

All 8 comments

It has to do with https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Console/Migrations/RefreshCommand.php, specifically lines 32, 38, and 45. It's because each of those calls confirmToProceed() in https://github.com/laravel/framework/blob/4.2/src/Illuminate/Console/ConfirmableTrait.php which is what prints that information.

Not sure of the best way to fix this, but maybe just passing the result of the first confirmToProceed for --force to the migrate:reset and migrate will work since confirmToProceed is already checked above.

You can use the --force command to force the migration if you wish. I'll look into suppressing the message if it's already been displayed.

Thank you Taylor, this generally works but doing php artisan migrate:refresh --seed -n --force still asks for confirmation once.

Hmm, OK. Thanks for the report.

On June 18, 2014 at 8:21:42 AM, Krzysztof Cynarski ([email protected]) wrote:

Thank you Taylor, this generally works, but doing php artisan migrate:refresh --seed -n --force still asks for confirmation once.

—
Reply to this email directly or view it on GitHub.

Maybe you could use yes | php artisan migrate:refresh --seed -n for temporary workaround.

@wajatimur Why both pipe yes _and_ pass -n? Ideally -n would be enough to make it shush.

@Arcrammer agreed using yes a bit overkill.

You could use expect for this:

[solution] laravel commandline auto yes seed artisan migrate
Permalink: http://www.ramonfincken.com/permalink/topic442.html

Was this page helpful?
0 / 5 - 0 ratings