Search code examples
laravelamazon-web-servicesdatabase-migration

How should i execute laravel migrations on an ecs cluster


I have an architecture built on AWS container service with laravel running as an api service to my JS app.

My question is: What is the best way to execute migrations?

My assumption is with multiple instances of the same laravel app running in the cluster I risk issues with the app themselves running the migrations at the same time. right ?

What is the best way to run migrations on the database with no downtime for our clients ? maybe an external service specifically designed to run migrations on a mirror db ?

Arch outline :

  1. ecs - laravel (5-10 services)
  2. ecs - JS (10-20 services)
  3. rds - mysql db (1 ec2 instance)

Solution

  • The app containers should not run administrative tasks like migrations, or you will get contention with multiple instances or useless operations at restart.

    From reading a few articles, the clean solution seems to run a one-off task to perform migrations. This is similar to hwo things work on Heroku for example.