Require application-owned backups for migrations

This commit is contained in:
Mikhail Chusavitin
2026-03-07 21:56:51 +03:00
parent 61ed2717d0
commit f55bd84668
2 changed files with 9 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
# Contract: Database Patterns (Go / MySQL / MariaDB)
Version: 1.4
Version: 1.5
## MySQL Transaction Cursor Safety (CRITICAL)
@@ -122,11 +122,12 @@ Rules:
- "Small" or "safe" changes are not exceptions.
- The operator must know how to restore from that backup before applying the change.
- If a migration or script is intended for production/staging, the rollout instructions must state the backup step explicitly.
- The backup taken before a migration must be triggered by the application's own backup mechanism, not by assuming `mysql`, `mysqldump`, or other DB client tools exist on the user's machine.
## Migration Policy
- Migrations are numbered sequentially and never modified after merge.
- Take and verify a fresh backup before applying migrations to any non-ephemeral database.
- Trigger, take, and verify a fresh backup through the application-owned backup mechanism before applying migrations to any non-ephemeral database.
- Each migration must be reversible where possible (document rollback in a comment).
- Never rename a column in one migration step — add new, backfill, drop old across separate deploys.
- Auto-apply migrations on startup is acceptable for internal tools; document if used.