# Cloudflare D1 database backing the pages users/sessions/page-metadata # tables (schema in ../migrations/schema.sql). SQLite-compatible; bound to # the Worker via the "DB" binding name in wrangler.toml. # NOTE: D1 must be created before the Worker script can bind to it # (chicken-and-egg). On first apply: tofu apply -target=cloudflare_d1_database.pages resource "cloudflare_d1_database" "pages" { account_id = var.cloudflare_account_id name = "pages" } # Export the D1 database ID so wrangler.toml's [[d1_databases]] placeholder # can be replaced with the real ID, and for use in wrangler migration commands. output "d1_database_id" { description = "D1 database ID — use to update wrangler.toml [[d1_databases]] database_id, and with: wrangler d1 execute pages --file ../migrations/schema.sql --remote" value = cloudflare_d1_database.pages.id }