This message was deleted.
s
This message was deleted.
l
That might be outside the scope of Pulumi. Where I work our servers that connect to RDS are in charge of keeping track of and running migrations. This is the pattern I’ve personally seen most often. Otherwise you’re stuck with a manual process of having to trigger a migration every time you create one. Forget to run the migration and now your sever falls over.
n
I was thinking of getting doing all the migrations before the main task runs
c
We actually do exactly this for the Pulumi Service. (Though we run the “database migrations container” on every update, to pick up any changes if needed.)
We ended up creating a custom Pulumi resource, that wraps the creation and execution of the Fargate task. And then hold off on updating our ECS services until the database migration task is “complete”. I’m happy to share the code with you, although there are a lot of baked-in assumptions that are specific to our environment. (Such as the use of ECS, so we run the task within the existing cluster. Or the specific directory we have our database migrations, and package up the container, etc.) But in short, if you would like to, “running a fargate task to run database migrations” is a thing you can do with Pulumi. But you’ll need to run it on ~every update to ensure that the deployed code matches the expected database schema. If you’d like to learn more about that approach, happy to help out. (But some other technique might be a better fit for your setup.)
n
wow, i'd really appreciate it, very new to pulumi so still learning/ trying to figure what works best.
m
I’ve been building an entrypoint script on the application container that’s responsible for running the migrations. When the task starts, migrations run, then the application starts.
c
Here is a suuuuper rough version of the relevant code. It’s definitely not in a form that can easily be reused, but if you are interested in getting this working could be used as a rough guide. https://gist.github.com/chrsmith/c212c97fc5250ff949f96e1355bd4a61
👍 2
💯 2
151 Views