From 8e249b8ebfe6fd4af2306f1c1134204c0e87964a Mon Sep 17 00:00:00 2001 From: mrizzi Date: Thu, 4 Jun 2026 19:09:52 +0200 Subject: [PATCH] docs: document migration reversibility requirement in CONVENTIONS.md Add explicit convention that migrations must implement down() for reversibility, referencing the test_migrations CI check that enforces this by running refresh (down+up). Implements TC-4512 Assisted-by: Claude Code --- CONVENTIONS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONVENTIONS.md b/CONVENTIONS.md index a076ec0fc..c1873126c 100644 --- a/CONVENTIONS.md +++ b/CONVENTIONS.md @@ -159,6 +159,7 @@ Any files modified by steps 1–2 (e.g., `openapi.yaml`, JSON schema files) must - Column additions use `add_column_if_not_exists()` - Drop operations use `.if_exists()` - Raw SQL loaded via `include_str!("migration_dir/up.sql")` +- Migrations must implement `down()` for reversibility — the `test_migrations` CI test verifies this by running `refresh()` (down + up) on every migration - Data migrations are separate from schema migrations, run via `trustd db data ` ## Rust Idioms @@ -926,7 +927,8 @@ idempotency guards, raw SQL loading, data migration separation). Additional conv - **Numbering**: increment by 10 (e.g., `m0002190` → `m0002200`) to leave room for insertions. -- **Reversibility**: implement both `up()` and `down()`. +- **Reversibility**: implement both `up()` and `down()`. The `test_migrations` CI test + runs `refresh()` (down + up) on every migration to enforce this. - **Schema vs. data**: schema migrations registered with `.normal()`; data backfills registered with `.data()`. Prefer no data in schema migrations — separate schema changes from data changes.