# Provision Cloudflare resources (R2 bucket, D1 database, DNS record,
# rate limits) from infra/. Reads credentials from infra/terraform.tfvars.
tofu-apply:
    cd infra && tofu init -input=false && tofu apply

# Apply schema migrations to the remote (production) D1 database.
# schema.sql is idempotent (CREATE ... IF NOT EXISTS), safe to re-run.
migrate:
    wrangler d1 execute pages --remote --file migrations/schema.sql -y

# Apply schema migrations to the local D1 database used by `wrangler dev`.
migrate-local:
    wrangler d1 execute pages --local --file migrations/schema.sql -y

# Build (via worker-build, configured in wrangler.toml) and deploy the Worker.
deploy:
    wrangler deploy

# Run the Worker locally (uses .dev.vars for vars/secrets).
dev:
    wrangler dev

# Full validation suite (see CLAUDE.md).
validate:
    cargo fmt
    cargo check --target wasm32-unknown-unknown
    cargo check
    cargo clippy --all-targets -- -D warnings
    cargo clippy --target wasm32-unknown-unknown -- -D warnings
    cargo test
