How to Compare Database Schemas Before Deploying
A step-by-step workflow for catching schema drift between staging and production in Python apps.
Paste two CREATE TABLE dumps from your FastAPI app — whether from alembic upgrade head output, SQLModel sync, SQLAlchemy reflect, or raw SQL. 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 Python-specific patterns that generic diff tools miss.
Compare alembic revision --autogenerate outputs before and after model changes. Verify that SQLAlchemy migrations produced exactly the schema you expected.
Diff schemas generated from SQLModel tables with Pydantic-validated columns. Detects Optional[int] → int nullability changes and Field default modifications.
Detects String(50) → Text(), Integer → BigInteger, and Enum value changes. Warns when length reductions could truncate data.
Validates relationship() and ForeignKey constraints. Detects missing or changed foreign keys that could break FastAPI's dependency-injected database sessions.
Compares PostgreSQL ENUM types and CheckConstraint declarations. Catches schema drift that breaks Pydantic model validation or OpenAPI schema generation.
Your schema never leaves the browser. Compare production FastAPI schemas safely without uploading sensitive table structures to a third-party server.
Run alembic upgrade head --sql or use pg_dump --schema-only on both environments (local vs staging, or staging vs production).
Copy the SQL into the two editor panes. Dialect auto-detects PostgreSQL or MySQL based on your DATABASE_URL in .env.
See added tables, dropped columns, type changes, and constraint modifications highlighted in color. Check for breaking changes before your next deploy.
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 users
ADD COLUMN is_active BOOLEAN DEFAULT TRUE;
ALTER TYPE status_enum ADD VALUE 'archived';
ALTER TABLE posts
ALTER COLUMN status TYPE status_enum;
ALTER TABLE comments
ADD CONSTRAINT comments_post_id_fkey
FOREIGN KEY (post_id) REFERENCES posts(id)
ON DELETE CASCADE;
ALTER TABLE products
ADD CONSTRAINT chk_price_positive
CHECK (price >= 0);
A step-by-step workflow for catching schema drift between staging and production in Python 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.