Top-level await in drizzle.config.ts
Is there a reason top-level
await
is only supported in migrate/studio commands and not generate/check, is this something that can be trivially added to drizzle-kit?
In my case I'm reading the secret asynchronously via AWS.
There's an open issue with a workaround posted, which does work, but is kind of gross: https://github.com/drizzle-team/drizzle-orm/issues/1982#issuecomment-2112340840GitHub
[FEATURE]: Support Top-level await in
drizzle.config.ts
· Issue #...Describe what you want I want to write a configuration as follows. Here, fetchDatabaseUri is a function that retrieves authentication information from AWS Secrets Manager and returns the database U...
9 Replies
is there any update on this? I'm struggling with the same thing
do you have a workaround
My workaround has been so far to fetch the secrete at build time and pass it down as an env variable. That way i don’t have to store and env file.
ah gotcha. I'm using SST and secrets make that more difficult to do. I suppose I can pass it in as an env var as well?
there isnt a way you know of to get migrate to work with top-level await is there? e.g. a patch to drizzle?
ohhh
for that...so, i don't use the drizzle.config.ts for the db credentials
I just directly pass it
whenever I initialize it
Buuut, for migrations, thats trickier. for that, i just have a migrate.ts file.
that will use that same db stuff...but this only worked in seed when using v2. Now that I'm migrating to v3 i realize i actually have to somehow create a soliton for the db connection exposed as a function like
getDBConnection(urlConnectionString: string)
And then i can just expose the migrate function to be passed as part of a sst local pulumi command. sst add command
but yeah all of this would not be a problem if we just had top level await on the drizzle config 😢