← 回到 Reading
ByteByteGo 2026-08-20

Schema Evolution: Changing the Contract Without Breaking What Runs

Schema changes 在 code review 時看似微不足道,卻代表著軟體系統中最棘手的修改類型之一。Migrations 往往在 staging 環境表現正常,卻在 production 環境失敗,這是因為多個 application versions 同時針對同一個 schema 運行。不相容問題也會隨著時間推移而產生,例如當歷史 database records、排隊中的 messages 或舊版 mobile clients 與新版 services 互動時。解決這些問題需要縝密的策略,包括 backward and forward compatibility、expand-and-contract migrations 以及 schema registries。

閱讀原文 ↗

Schema Evolution:在不破壞運行中系統的情況下修改 Contract

Schema changes 在 code review 時看似微不足道,卻代表著軟體系統中最棘手的修改類型之一。Migrations 往往在 staging 環境表現正常,卻在 production 環境失敗,這是因為多個 application versions 同時針對同一個 schema 運行。不相容問題也會隨著時間推移而產生,例如當歷史 database records、排隊中的 messages 或舊版 mobile clients 與新版 services 互動時。解決這些問題需要縝密的策略,包括 backward and forward compatibility、expand-and-contract migrations 以及 schema registries。

  • Schema changes 在 review 時通常看起來微不足道(例如重命名 column 或刪除未使用的 field),但可能會導致廣泛的 production failures。
  • 當應用程式的兩個版本同時查詢同一個 database,而其中只有一個版本支援已更新的 schema 時,往往會引發 deployment issues。
  • 在舊版 schema 下寫入的資料(例如歷史資料庫 rows、佇列訊息,或是來自舊版 mobile apps 的 request),通常必須由較新的應用程式碼來處理。
  • 管理 schema evolution 需要像是 expand and contract migrations 等方法論,以及如 schema registries 等工具。