Best practice on running migrations
I have a serverless framework setup and during my testing I've been using the db push but now that I have something setup to actually test my migrations I'd like to run:
whats the best path to actually running this from an npm script or from a ci for example. Or even locally without using push. Basically, I've generated my sql migrations but I now need to run them.
12 Replies
I’ve been wondering the same thing, keen to hear what ppl say
We currently have a lambda function dedicated to running migrations, using
await migrate(...)
. At least at the time, drizzle wasn't safe for running migrations across multiple machines concurrently AFAIK.
We run this manually at the moment, but soon plan on making it a custom cloudformation resource so that it runs as part of our CDK deployment (I'm sure the same can be done in sls). Or a more trivial approach, we will just invoke it as part of our deployment pipelineI'm doing that on ci/manually.
I remember it is planned to be added in drizzle-kit
Or some of us will add that when it is open sourced
Looks great! Probably going to use this
thank you! I was having issues with running it locally especially because it needed to be transpiled first. I"ll try this out but would love to still have a local alternative
yea you need to run it with ts-node (like in my screenshot) or tsx or tsm 🫣
@Raphaël M (@rphlmr) ⚡ this might be a silly question but how did you get around this specific error:
How do you get this error?
I think I got it figured out, it was due to my tsconfig
thank you
and what did you change in your tsconfig?
I had to change it to be commonjs because it was complaining about using imports