Schema

Know what your database changes will break.

Read a migration alongside the queries and application versions that still rely on the old schema.

Schema / shop-api Design preview

Pull request #84

Rename the order total

Review required
Column comparison public.orders
· id uuid
− total_cents integer
+ amount_cents integer
· currency text

042_rename_total.sql

ALTER TABLE orders
RENAME COLUMN total_cents
TO amount_cents;

Dependency review

2 dependent readers

Materialized view receipt_totals orders.total_cents
Application query receipt-worker SELECT total_cents

! The current worker still requests the old column name.

Connect a proposed column change to the readers it affects.

A migration can execute successfully while an older worker continues to read the column it removed. Compatibility depends on the readers still in circulation.

Give old readers time to move.

Expand the schema, backfill existing rows and move readers before contracting it. Review each step while the change is still in a pull request.

Schema / shop-api Design preview

Alternative migration sequence

Keep the old reader working

orders
  1. 01
    Expand

    Add amount_cents as a nullable integer.

    Both application versions can read the original column.
  2. 02
    Backfill

    Copy total_cents into amount_cents.

    Dual-write new orders and verify row counts and values.
  3. 03
    Move readers

    Update the receipt query and view.

    Deploy the new reader before retiring the old one.
  4. 04
    Contract

    Remove total_cents in a later migration.

    Wait until all running revisions have stopped reading it.
Migration history 041 · Receipt totals view 042 · Column rename in review
The migration plan makes the compatibility window explicit.
Dependency evidence
Review named queries and consuming services beside each changed column. An unknown consumer remains an open question.
Destructive changes
Dropping a column removes data even if every known query compiles. Review the backfill and retention decision separately.
Migration history
Preserve the transition order and revision so a reviewer can place a proposed change in the sequence already applied.

How Schema fits into the planned x1991 workspace.

Availability

Concept

Release history

Schema is a proposed tool. The interfaces use illustrative data. A public release date has yet to be announced.

Read the Schema concept guide