HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to run database migrations in an auto-scaled group

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
groupautodatabasemigrationsscaledhowrun

Problem

We are just about to move from a monolithic architecture to an auto-scaled group and I'm not sure how I should be running my database migrations (Laravel).

I am thinking that a script will run when a new box comes online, this will git pull my latest code down. Should this script also execute my database migration? I am not sure how I can get it run on only one box?

Solution

How are you doing your deploys? Nuke + rebuild the ASG (whether one node at a time, or by replacing the whole group at once), or do you have a script that redeploys all of your active nodes?

And also, how are you triggering your deploys?

Ideally you want to be running/triggering deploys from some form of CI server like Bamboo or Jenkins. If you're doing this, you can run your DB migrations from the build server (or its component build agent instances).

This would allow you greater control over your environment, as you could, for example, restore DB from snapshot if the deployment fails.

Context

StackExchange DevOps Q#2152, answer score: 1

Revisions (0)

No revisions yet.