<!-- example:database-migration -->
# Database migration specification example

A planned MySQL-to-PostgreSQL migration during a maintenance window.

- [HTML version](https://specifica.org/examples/database-migration/)
- [Specifica format](https://specifica.org/format.md)
- [Editable Playground](https://playground.specifica.org/): choose Database migration and Simple

## spec.md

### 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

- [ ] 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

Optional workflow reference: copy and validation rules can be checked before merge; the delivery team still owns cutover and rollback. [Cognium Autonomous Loop](https://cognium.net/how-it-works/).
