← Tutti i modelli

Migrazione senza interruzioni, con backfill e piano di rollback.

Spec — Database migration

Status: draft · Created: 2026-10-12

1. Context and goal

A column changes shape on a live table without downtime, with a backfill and a tested way back.

2. Functional requirements (EARS)

  • FR-1: THE migration SHALL add the new column as nullable, without a table rewrite or a long lock.
  • FR-2: WHILE the migration runs, THE application SHALL write both the old and the new column.
  • FR-3: THE backfill SHALL copy existing rows in batches of at most 10,000 with a pause between batches.
  • FR-4: IF the backfill stops, THEN running it again SHALL continue from the last finished batch.
  • FR-5: WHEN every row is backfilled and checked, THE application SHALL read from the new column.
  • FR-6: THE constraint on the new column SHALL be added as not valid first and validated afterwards.
  • FR-7: THE rollback plan SHALL return reads to the old column at any step before the old column is dropped.
  • FR-8: THE old column SHALL be dropped only in a later release, after one release reading the new column.

3. Out of scope

  • Changes across more than one table.