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
Walshy
Walshy4d ago
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
jjjrmy
jjjrmyOP4d ago
@Walshy | Workers/Pages but I don't actually have the SQL files. I'm using the Sutando library
Sutando
Next Generation Frontend Tooling
jjjrmy
jjjrmyOP4d ago
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
Walshy
Walshy4d ago
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
jjjrmy
jjjrmyOP4d ago
yes I used Drizzle in the past @Walshy | Workers/Pages there is this example but it is also using SQL files.

Did you find this page helpful?