Migration safety: dry-run plan, lock-aware advisor, one-click rollback

Aperta
#58 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go, react, sql, typescript
Ambito
backend, cli, databases

Direzione di ricerca

This is a design-scale proposal covering a migration planner, runner, reversible down migrations, schema snapshots and an admin UI history view; no files or entry points are named. Start by reading how AutoMigrate is currently invoked and where the grit CLI registers its commands, then sketch the plan/up/down/restore command surface before touching implementation. Done means grit migrate plan flags an unsafe NOT NULL add before execution, a failed migration can be restored to its pre-state in under 30s, and migration history is diff-able in the admin UI.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Vision

Database migrations are the highest-blast-radius operation in any deploy. "Migration locked the table for 90 seconds during peak" is a story every senior engineer has lived. The framework's AutoMigrate is friendly for prototypes but dangerous at scale.

Proposal

A migration toolchain that grows up with the app:

  • `grit migrate plan` — prints the SQL the migration will run, the estimated lock time per statement, and warnings for known-dangerous patterns:
    • `ALTER TABLE … ADD COLUMN NOT NULL` without a default → suggests two-step migration
    • `ALTER TABLE … ADD INDEX` → warns about lock duration on N-row tables
    • `DROP COLUMN` → blocks unless explicitly approved (data loss)
    • Destructive ops on tables > N rows → require an explicit `--i-understand` flag
  • `grit migrate up` — runs the plan with progress reporting + automatic transaction wrap
  • `grit migrate down` — auto-generated reverse migrations for every `up` (where reversible)
  • Schema snapshots before/after every migration → `grit migrate restore ` rolls back to a snapshot
  • Migration history in admin UI with diff view per migration

Why this is differentiating

Liquibase and Flyway exist; nothing comparable for Go + GORM + opinionated app frameworks. "Run a safe migration" is a recurring stress event for every engineering team.

Acceptance

  • `grit migrate plan` catches an unsafe `NOT NULL` add before it locks production
  • A migration that fails halfway can be rolled back to its pre-state in <30s
  • Migration history is queryable + diff-able in the admin UI
Lingua principale
Go
Stelle
152
Fork
20
Merge medio
1g 49m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MUKE-coder/grit

Tutte le issue di MUKE-coder/grit

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.