--- id: migra version: "3.0.1663481299" license: Unlicense license_treatment: permissive maintenance: aging --- # migra — Like `diff` but for PostgreSQL schemas License: permissive · Maintenance: aging · Downloads: 246.9K/mo ## What it is and what it does migra is a schema diff tool for PostgreSQL that automatically detects differences between two database schemas and generates the SQL statements needed to transform one into the other. Instead of writing migrations by hand, you point migra at a source and target schema, and it figures out the alter statements required—column additions, constraint changes, and other modifications across most PostgreSQL features. It works both as a command-line tool and as a library you can call from Python scripts. The tool is designed to make schema migrations less tedious and error-prone by automating the comparison and SQL generation. You can use it to synchronize a development database from application models, make schema changes testable, or simply understand what structural changes exist between two database versions. It requires PostgreSQL >= 9 and Python >= 3.7, with minimal dependencies (sqlbag, six, schemainspect). Use it for: - Generate migration scripts automatically when your application schema definition changes, reducing manual SQL writing. - Synchronize a development database schema with your application's ORM or schema models without hand-coding migrations. - Compare production and staging database schemas to identify drift and generate corrective SQL statements. - Test schema changes in a controlled way by generating and reviewing the exact SQL before applying it. - Audit schema differences between database versions or environments for compliance or debugging purposes. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. migra compares PostgreSQL database schemas and generates the SQL statements needed to transform one schema into another, automating schema migrations from the command line or within Python scripts. Yes, if you work regularly with PostgreSQL schema migrations and want to reduce manual SQL writing. The low install friction and permissive license make it easy to try. However, the aging maintenance status (latest release 2022, though recent commits exist) means you should verify compatibility with your PostgreSQL version and be prepared to contribute fixes if needed. No known vulnerabilities. ## Install pip install migra uv add migra poetry add migra ## Installing migra Before you install: Low install friction with only three runtime dependencies. Maintenance status is aging—the latest release was in 2022, though the repository remains active with recent commits and no archived status. License in practice: Licensed under the Unlicense, a permissive public-domain-like license that places no restrictions on use, modification, or distribution. Quickstart: $ pip install migra $ migra postgresql:///source_db postgresql:///target_db Or in Python: from migra import Migration from sqlbag import connect m = Migration(connect('postgresql:///a'), connect('postgresql:///b')) print(m.sql) Requires PostgreSQL >= 9 and Python >= 3.7, < 4. Both source and target databases must be accessible via connection strings. Verify before relying: - Extent of PostgreSQL feature coverage beyond the 'most features' claim in the description - Performance characteristics when comparing large or complex schemas - Whether the aging maintenance status affects compatibility with recent PostgreSQL versions ## Package facts - License: Unlicense (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 246.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags postgres schema diff, database migration generator, postgresql schema comparison, auto-generate sql migrations, schema synchronization tool, database schema versioning, postgres schema changes, schema-migration, postgres-tools, sql-generation [View on SkillFed](https://skillfed.io/packages/migra) · [View on PyPI](https://pypi.org/project/migra/)