Quant with Vahab
Quant Systems Lab · Control Systems for Quantitative Finance

Schema Migrations and Backward Compatibility

Alembic-style migrations evolve the database safely by applying small, versioned changes that keep old and new code working.

Explanation

Schema migrations are versioned scripts that transform the database from one structure to another in a controlled way.

Additive changes come first: new tables or columns are introduced in a backward-compatible format and backfilled.

Application code is then updated to use the new schema before old structures are finally removed in a later migration.


databasemigrationsbackward compatibilityalembic
Interactive visualisation
Schema migrations and backward compatibility
Evolve data safely without breaking old and new code.
Migration step
Current phase
1) Add new schema (compatible)
Deployment risk
18%
Principle: make additive changes first. Delete later, only after code is switched and stable.
Databaseold_tablekeptnew_tableactiveApplicationRunning:Old code1) Add new schema (compatible)Expand → backfill → switch → contract
Interpretation
  • Backward compatibility means both code versions can run during a rollout.
  • Backfill is a deliberate data operation, not a side effect of new code.
  • Deletion is the last step, after stability is proven.