Cloudflare Worldedge community field guide

回顧版月刊 / 2024-09

D1:讓 schema 承擔 contract

Relational data 需要 migrations、constraints、query ownership 與 recovery,不只是一個 SQL endpoint。

期號
09 / 32
首次發布
來源查核
檔案誠信

月份代表課程編排位置;本文首次發布於 2026-08-10,不冒充歷史發布紀錄或過往活動。

01 / DECISION

何時值得加入這個 primitive

當 relationship 與 SQL query 是核心,且應用能管理明確 schema lifecycle 時使用 D1。

02 / ARCHITECTURE

建立最小且站得住腳的路徑

先定義 constraints 與 indexes、撰寫 forward migration、綁定 prepared statements、分頁 reads,並定義 backup 與 deletion。

  1. 01先命名 contract

    當 relationship 與 SQL query 是核心,且應用能管理明確 schema lifecycle 時使用 D1。

  2. 02只加入一個 primitive

    先定義 constraints 與 indexes、撰寫 forward migration、綁定 prepared statements、分頁 reads,並定義 backup 與 deletion。

  3. 03保留 failure evidence

    在 disposable database 套用 migrations、測試 constraints 與 empty results、檢查 query plan,並演練 restore 或 rebuild。

03 / REPRODUCE

有證據,再有信心

在 disposable database 套用 migrations、測試 constraints 與 empty results、檢查 query plan,並演練 restore 或 rebuild。

npx wrangler d1 migrations apply DB --local

04 / BOUNDARY

Production boundary

Database binding 不會消除 query cost、contention、migration risk,也不會免除 data minimization。

05 / FIRST-PARTY SOURCES

讓第一方來源保持權威

產品行為、限制、價格與供應狀態會改變;採取行動前請重新核對這些來源。

01 / SOURCECloudflare D1https://developers.cloudflare.com/d1/