How to Compare Database Schemas Before Deploying
A step-by-step workflow for catching schema drift between staging and production in Rails apps.
Paste two db/schema.rb versions or raw CREATE TABLE dumps from your Rails app. Spot every table, column, index, and constraint change instantly. Get ready-to-run ALTER TABLE scripts for PostgreSQL or MySQL — all in your browser.
No account required. No data leaves your device.
SchemaLens understands Rails-specific patterns that generic diff tools miss.
Compare two versions of db/schema.rb to see exactly what changed between migrations. Perfect for reviewing PRs that include schema changes.
Warns before rails db:migrate runs dangerous changes. Detects column drops, type changes, and NOT NULL additions that could break ActiveRecord models.
Detects changes to single-table inheritance (type) and polymorphic association columns (*_type, *_id). Validates reference columns stay in sync.
Validates created_at, updated_at, lock_version, and other Rails magic columns. Warns when timestamps are missing from new tables.
Diffs t.references, t.belongs_to, and t.index changes. Detects missing foreign keys and composite index modifications.
Your schema never leaves the browser. Compare production Rails schemas safely without uploading sensitive table structures to a third-party server.
Run rake db:schema:dump on both environments, or use pg_dump --schema-only (PostgreSQL) / mysqldump --no-data (MySQL) for raw SQL.
Copy the SQL into the two editor panes. Dialect auto-detects PostgreSQL or MySQL based on your Rails database.yml.
See added tables, dropped columns, type changes, and constraint modifications highlighted in color. Check for breaking changes before db:migrate.
Export ALTER TABLE scripts, save as Markdown for PR descriptions, or generate rollback SQL. Run in staging, then production.
SchemaLens generates production-ready ALTER TABLE scripts for every change it detects.
ALTER TABLE "comments"
ADD COLUMN "post_id" BIGINT;
CREATE INDEX "index_comments_on_post_id"
ON "comments" ("post_id");
ALTER TABLE "users"
ALTER COLUMN "username" TYPE VARCHAR(50);
ALTER TABLE "products"
ADD COLUMN "created_at" TIMESTAMP NOT NULL,
ADD COLUMN "updated_at" TIMESTAMP NOT NULL;
CREATE UNIQUE INDEX "index_users_on_email"
ON "users" ("email");
A step-by-step workflow for catching schema drift between staging and production in Rails apps.
Learn how to catch dropped columns, missing indexes, and type changes before they cause incidents.
Deep-dive into PostgreSQL-specific schema comparison features and migration generation.
Join thousands of developers who use SchemaLens to catch schema changes before they hit production.
Start Comparing FreeFree for up to 15 tables. Lifetime Pro — $39 once.