Migration · Simple example

Database migration specification example

A planned MySQL-to-PostgreSQL migration during a maintenance window. The specification separates copy and validation work from the production switch, with clear cancellation and rollback conditions.

database migrationMySQLPostgreSQLrollback plan

spec.md Requirements and edge cases

The success checks and abort conditions are explicit before the maintenance window begins.

# Database migration — spec

## Requirements

- [ ] A script copies every table from MySQL to PostgreSQL with the same rows.
- [ ] After the copy, row counts match for every table, and a report lists them.
- [ ] The app runs its test suite against PostgreSQL before the switch.
- [ ] During the window the app shows a maintenance page; afterwards it uses PostgreSQL.
- [ ] A rollback script points the app back at MySQL within five minutes.

## Edge Cases

- A column type has no exact match (MySQL `TINYINT(1)`) → mapped by a listed rule (`boolean`), never guessed.
- The copy runs past the window → the switch is cancelled and MySQL stays live.
- Zero dates (`0000-00-00`) in MySQL → stored as null and listed in the report.

tasks.md Build order

The plan prepares and rehearses the reversible switch before production changes.

# Database migration — tasks

## Build order

- [ ] Type mapping table, reviewed
- [ ] Copy script with batches and a run record
- [ ] Count check and report per table
- [ ] Test suite green against PostgreSQL
- [ ] Switch and rollback scripts, rehearsed on a copy