"drizzle-orm/planetscale-serverless/migrator" in cf workers
Hey guys in cf workers you don't have access to the file system, how hard would it be to provide migrations to the
migrate
function?
something like this:
5 Replies
cc @alexblokh @Dan Kochetov
hey, @chronark
SQL migrations with D1 are not supposed to be run within worker, those should be run with Wrangler
I suppose our current format is interoperable with the one expected by wrangler
oh I'm not talking about d1, but mysql/pscale
but that's not really the point
I know I'm hacking here
the idea is to offer a docker image of our api (I have it running using
workerd
and have an api route on it, that would migrate the attached db + seed data
basically you'd do
I know there are other ways to achieve it, but this would be pretty nice
the problem is that the migrate
function tries to read the migration files from the file system, which is just not really a thing in workerd
, but I could embed these during docker build timeI would love the ability to do something similar, run the migrate programmatically without having to do a generate and migrate. https://discord.com/channels/1043890932593987624/1202633333536718908
@chronark I sort of grasp what you're trying to achieve
on AWS there's a
custom resource
lambda which is invoke during deployment which is supposed to run migrations for the serverless environment
by having curl http://localhost:8787/v1/seed
you sort of mimic that but it will run after the actual infra deployment which can lead to race conditions
for your usecase I would say something like what we have for Expo is the potentially the best solution
let the bundler pack SQL files into the bundle for this lambda
or just pack and expose SQL files in your workerd
container
if that still doesn't suite your needs - I'd love to hop on the call and groom through potential solutions
yeah, that's something we've discussed internally and are aiming to do
we didn't prioritise it since we already have push
which sort of partially solves the issue for now