Rails schema diff — free to use

Rails Schema Diff.
Compare db/schema.rb.
Zero setup.

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.

Built for Rails & ActiveRecord workflows

SchemaLens understands Rails-specific patterns that generic diff tools miss.

💎

db/schema.rb Diff

Compare two versions of db/schema.rb to see exactly what changed between migrations. Perfect for reviewing PRs that include schema changes.

🛡️

Migration Safety Checks

Warns before rails db:migrate runs dangerous changes. Detects column drops, type changes, and NOT NULL additions that could break ActiveRecord models.

🧬

STI & Polymorphic

Detects changes to single-table inheritance (type) and polymorphic association columns (*_type, *_id). Validates reference columns stay in sync.

⏱️

Timestamp & Magic Columns

Validates created_at, updated_at, lock_version, and other Rails magic columns. Warns when timestamps are missing from new tables.

🔗

Reference & Index Changes

Diffs t.references, t.belongs_to, and t.index changes. Detects missing foreign keys and composite index modifications.

🔒

Privacy First

Your schema never leaves the browser. Compare production Rails schemas safely without uploading sensitive table structures to a third-party server.

How it works with Rails

1

Export your schemas

Run rake db:schema:dump on both environments, or use pg_dump --schema-only (PostgreSQL) / mysqldump --no-data (MySQL) for raw SQL.

2

Paste into SchemaLens

Copy the SQL into the two editor panes. Dialect auto-detects PostgreSQL or MySQL based on your Rails database.yml.

3

Review the diff

See added tables, dropped columns, type changes, and constraint modifications highlighted in color. Check for breaking changes before db:migrate.

4

Copy the migration

Export ALTER TABLE scripts, save as Markdown for PR descriptions, or generate rollback SQL. Run in staging, then production.

Rails migration examples

SchemaLens generates production-ready ALTER TABLE scripts for every change it detects.

Add a reference with index

ALTER TABLE "comments"
  ADD COLUMN "post_id" BIGINT;
CREATE INDEX "index_comments_on_post_id"
  ON "comments" ("post_id");

Change string column length

ALTER TABLE "users"
  ALTER COLUMN "username" TYPE VARCHAR(50);

Add timestamps to existing table

ALTER TABLE "products"
  ADD COLUMN "created_at" TIMESTAMP NOT NULL,
  ADD COLUMN "updated_at" TIMESTAMP NOT NULL;

Add unique index

CREATE UNIQUE INDEX "index_users_on_email"
  ON "users" ("email");

Related guides

Ready to diff your Rails schemas?

Join thousands of developers who use SchemaLens to catch schema changes before they hit production.

Start Comparing Free

Free for up to 15 tables. Lifetime Pro — $39 once.