Migration Preview

Migration Preview is a copy-paste React component that stops helps prevent a migration locking a production table for hours before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/migration-preview
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsHelps prevent a migration locking a production table for hours

Was this component page useful?

How do I install Migration Preview?

pnpm dlx shadcn@latest add @bollard/migration-preview

The files land in your project. They're yours to edit.

How do I use Migration Preview in React?

migration-preview-usage.tsx
import { MigrationPreview } from "@/components/ui/migration-preview"

return <MigrationPreview label="20261014_add_order_region.sql" defaultValue={migration} tableSizes={{ orders: 12_400_000, customers: 86_000 }} />

What input mistakes does Migration Preview catch?

  • Locks each step takes and what other sessions can't do meanwhile
  • Steps that rewrite or scan every row of a large table (from tableSizes)
  • Dropped tables and columns that can't be undone
  • NOT NULL without a default on existing rows, and renames that break running code
  • CREATE INDEX CONCURRENTLY inside a transaction, and missing lock_timeout

What props does Migration Preview accept?

MigrationPreview props
PropTypeDefault
value

Controlled migration SQL (Postgres).

string—
defaultValue

Initial SQL when uncontrolled.

string""
onValueChange

Called with the new SQL when a fix is applied or undone.

(value: string) => void—
locale

Number format for row counts.

string—
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string (`_one` keys are the singular forms). `{count}`, `{n}`, `{rows}`, `{detail}` are filled in.

Partial<MigrationPreviewMessages>—

* required. Also accepts the native props of <section> (className, aria-*, data-*…), passed through to it.

How is Migration Preview accessible?

  • Section labelled by its title; summary uses role=status
  • Each step is labelled with its number; icons are aria-hidden
  • Fix and undo are buttons, and focus moves to Undo after a fix

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Run migrations with lock_timeout and statement_timeout, test on a production-sized copy, and keep a rollback plan.

  • Postgres only, and lock behaviour can differ between versions
  • A static read: it doesn't run the SQL or know current load
  • Row counts only if you pass tableSizes

What expensive mistakes does Migration Preview stop?

Helps prevent a migration locking a production table for hours

Also known as

db migration · postgres · alter table · lock_timeout · create index concurrently · prisma migrate · drizzle · sql preview

Field type

What dependencies does Migration Preview require?

Migration Preview facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameMigration Preview
Registry identifier@bollard/migration-preview
Install commandnpx shadcn@latest add @bollard/migration-preview
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Migration Preview

How does Migration Preview protect destructive mutations?

Migration Preview prevents a migration locking a production table for hours. Enforces deliberate friction against Locks each step takes and what other sessions can't do meanwhile, Steps that rewrite or scan every row of a large table (from tableSizes), Dropped tables and columns that can't be undone, NOT NULL without a default on existing rows, and renames that break running code, CREATE INDEX CONCURRENTLY inside a transaction, and missing lock_timeout. Limitation: authorize migration-preview mutations on the server.

How do I install migration-preview with shadcn?

Run `npx shadcn@latest add @bollard/migration-preview`. Sources added: registry/default/migration-preview/migration-preview.tsx, registry/default/migration-preview/review-migration.ts. Package requirements: lucide-react.

What props customize Migration Preview?

Migration Preview accepts `value`, `defaultValue`, `onValueChange`, `locale`, `label`. Configures db migration, postgres, alter table behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of migration-preview?

Postgres only, and lock behaviour can differ between versions. A static read: it doesn't run the SQL or know current load. Row counts only if you pass tableSizes Server requirement: Run migrations with lock_timeout and statement_timeout, test on a production-sized copy, and keep a rollback plan.

How does Migration Preview meet accessibility guidelines?

Section labelled by its title; summary uses role=status. Each step is labelled with its number; icons are aria-hidden. Fix and undo are buttons, and focus moves to Undo after a fix. Minimizes errors: migration took down production, alter table locked table.

Which components pair with Migration Preview?