1

I was wondering if it's a good practice to run automatically php artisan migrate in production after a deploy on Heroku.

Thanks for your help!

2 Answers2

1

I think it depends on how well you test your code and migrations. If you test your code with every deploy and ensure everything works as it should, you could migrate. Do note that migrating takes time, and this means you should shut down the site until the migrations are done, with Laravel maintenance mode for example (https://laravel.com/docs/5.7/configuration#maintenance-mode).

If you don't test your code, you should. If you automatically deploy to a server you have to be 100% certain the code will work.

Tim
  • 551
  • 3
  • 23
  • Currently I'm using TTD/CircleCI to make sure my code works anytime I deploy. So should I run `php artisan down`, `php artisan migrate` and `php artisan up`? – Simone Bernardi Oct 09 '19 at 08:36
  • I would do it this way, but this means there will be downtime. So if you can't afford any downtime you have to search for an alternative where the code is deployed on another server, and DNS-records are altered to point to that server. – Tim Oct 09 '19 at 09:04
0

If you want 0 downtime, you cannot always migrate after a deployment. because Models / code will use columns or tables that are not present yet. So depending on your need for 0 downtime you have to make this choice.

online Thomas
  • 8,864
  • 6
  • 44
  • 85