Skip to content
available for projects000%
All writing
ENTRY-020Infrastructure7 August 2026 · 1 min read

SER-02 · SER-02.03 · From Prototype to Production

From AI Prototype to Production Schema: Data Modeling and Migration Strategy

A production data model is not a SQL version of the current JSON. Define the domain truth first, then migrate existing data toward it without losing compatibility.

Prototype schemas optimize for learning. Production schemas must protect ownership, relations, invariants and recovery. The migration between those worlds should be treated as an operational protocol rather than a one-off SQL script.

1. Model the domain, not the current tables

I identify entities, owners, required relationships, uniqueness rules and deletion semantics before redesigning tables. Existing schema is evidence, not the specification.

ts
type DomainInvariant = {  entity: string;  owner: "user" | "workspace" | "system";  uniqueBy: string[];  requiredRelations: string[];};

2. Move assumptions into database guarantees

Critical truths belong in NOT NULL, UNIQUE, FOREIGN KEY, CHECK, RLS or server-side policy. A UI that happens not to create invalid data is not a data-integrity strategy.

3. Use expand → migrate → contract

Add the new structure first, make the application compatible with both versions, backfill and validate, switch reads and writes, then remove the old structure after the compatibility window closes.

txt
EXPAND   -> add new schemaMIGRATE  -> backfill and validateCUTOVER  -> move reads/writesCONTRACT -> remove legacy fields

4. Treat backfills as operations

Large backfills need batching, idempotency, retry rules and observability. They should be safe to resume and make progress measurable.

  • Measure nulls and distributions before migration.
  • Batch large updates.
  • Make every batch idempotent.
  • Delay strict constraints until backfill is complete.
  • Compare old and new read paths before cutover.
  • Plan application and schema rollback together.

5. Design indexes from real queries

Normalization does not guarantee performance. Indexes should follow measured filters, sort patterns and tenancy boundaries rather than intuition alone.

6. Rollback is a compatibility problem

Once a new application version writes data the old version cannot understand, deployment rollback may become unsafe. Some migrations require forward-fix rather than down migration; that choice should be explicit before release.

  • Database
  • Migration
  • Postgres
  • Supabase
  • Data Model
  • Production

SER-02 · SER-02.03

From Prototype to Production

Turning a working MVP into a dependable product: production checks, modular refactoring, data migration, audits, rewrite decisions and release gates.

AVAILABLE FOR PROJECTS · PRODUCT & SYSTEMS ARCHITECT · TAKEOVER / STABILIZE / OPERATE · WEB · ANDROID · WINDOWS · AHMET CANAL

Contact

Has your product grown faster than its system?

Send the current situation, your biggest blocker and the outcome you want. We will clarify scope together.

Availability

Open to new consulting and project-based work.