People searching “Laravel migrate on deploy” hit the site once so AppServiceProvider can run migrations. Run them in the release, before the new code serves traffic. The deploy guide lists this command.
TL;DR
- php artisan migrate —force belongs in the release step.
- A Vue button must not be the thing that migrates production.
- Do not call
Artisan::call('migrate')from a controller the Vue page can hit. - Do not migrate from a queued job “so the request stays fast”.
The fix#
php artisan migrate --force--force is required when APP_ENV is production. It answers yes. Read the migration before you ship it. A down() that drops a column is not a small mistake.
What to avoid#
Gotcha
Do not call Artisan::call('migrate') from a controller the Vue page can hit. Two deploys, or two curious browsers, should not race that. Do not migrate from a queued job “so the request stays fast”. The new code and the old schema would be live together until the job runs.
FAQ#
How do I run migrations in the release, not in a request?
php artisan migrate --force belongs in the release step. A Vue button must not be the thing that migrates production.
What goes wrong with Laravel migrate on deploy?
Many developers hit the site once so AppServiceProvider can run migrations. Do not call Artisan::call('migrate') from a controller the Vue page can hit.



