Update D1 schema on build of Pages project?

I want my Pages project deployments to automatically update the attached schema (creating tables, etc.) when the project is updated/built. How should I do that? My current alternative to automate this is just to prepend 'create table if not exists' in all of my worker functions, but I'd prefer to do it at or immediately after build time.
2 Replies
kalaivanan
kalaivanan8mo ago
Try using drizzle orm and migrate while deployment. Easy way is include 'npm run migrate' in deploy script.
jordanfinners
jordanfinners7mo ago
You could create the D1 migrations and then run the wrangler command as part of the CI deployment https://developers.cloudflare.com/d1/reference/migrations/
Cloudflare Docs
Migrations · Cloudflare D1 docs
Database migrations are a way of versioning your database. Each migration is stored as an .sql file in your migrations folder. The migrations folder …
Want results from more Discord servers?
Add your server