Are there any common patters for data migrations a...
# sst
k
Are there any common patters for data migrations and or seeding data for SST/CDK? or is this more of a dependency on ORM/DAL selection
t
Probably the latter but you can use sst.Script to trigger those as part of the deploy process
k
Perfect
o
We deploy migrations as stacks, then run them via the AWS console. For large migrations having the same tooling as the app (SQS, step functions, running lambdas in parallel) is super useful. We usually code them to have a preview mode, run it to make sure the existing data looks like we expect, then run it again with the preview flag set to false
k
Interesting... so your migrations are a stack that gets deployed and then executed in the AWS Console?
o
yeah, and a single migration could be multiple lambdas that need to be orchestrated. Some of them are just a single lambda script though
k
And you control Authorization for the lambda to schema and databases via the CDK definition?
o
yeah - same as a normal lambda
k
Super interested in this way of approaching migrations... especially where a data related deployment would often need to be deployed ahead of the application
t
I've been thinking about this approach as well. A migration is really just some functionality that needs to run so no need to treat it like something outside of your normal application
k
I've thought of it like Rails used to be and or the way TypeORM handles it.. .that said in a modern architecture there are all kinds of resources for an application that might need a "migration" like activity.... nice to leverage the framework for that
o
I’d like to create a layer on top of that, to track what migrations/ops scripts exist, their parameters, and audit log of when they’ve been run and outputs. I’d probably have the build export some metadata, expose it via an API, have it store state either in dynamo or faunadb, build a UI in retool