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

Open
#58 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go, react, sql, typescript
Domain
backend, cli, databases

Research direction

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.

Written by the indexing model from the issue text.

Description

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
Dominant language
Go
Stars
152
Forks
20
Avg merge
1d 49m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MUKE-coder/grit

All issues in MUKE-coder/grit

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.