Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel migrate on production server

I'm using Laravel and as part of my deploy routine I have the command

RUN php artisan migrate

Since I'm in production, I get the error

Application in production, Command Cancelled!

The fix is easy: RUN php rankbot/artisan migrate --force but I feel this is not the right way to do it? What's the best way to ensure the DB schema is always up to date?

like image 207
Stefano Giacone Avatar asked Oct 11 '17 21:10

Stefano Giacone


1 Answers

This is the right way to go about it.

When you run a migration on production, you best be sure what it's going to do to your database, as some actions might not be rollbackable.

The confirmation prompt is there to make you stop and think twice before potentially cause harm.

Some migration operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database, you will be prompted for confirmation before the commands are executed. To force the commands to run without a prompt, use the --force flag

https://laravel.com/docs/5.5/migrations#running-migrations

like image 78
Unamata Sanatarai Avatar answered Sep 20 '22 17:09

Unamata Sanatarai