Access Bindings After Build (From Command)
I'm trying to run some command that requires access to the bindings (D1) in a build command after it's built.
I'm not seeing my DB binding inside of
process.env
5 Replies
Bindings won't exist in the build, a build is just a unix container not the Workers runtime
If you want to do like a migration I suggest running the wrangler command for it
npx wrangler d1 migrations apply
That'll use the HTTP API
so I'm trying to figure out how I can run the Sutando migrations. basically I just have a repo that when I push code to - I want to have it run on build or something. since ideally this repo doesn't have any endpoints, it just handles the database
Probably a question best asked for them
Personally I use Drizzle which generates sql migrations and run them that way. Most tools do it this way
yes I used Drizzle in the past
@Walshy | Workers/Pages there is this example but it is also using SQL files.