A Go library for diffing Postgres schemas and generating SQL migrations with minimal downtime and locks.
pg-schema-diff is a Go library that computes differences between PostgreSQL database schemas and generates SQL migration scripts. It solves the problem of safely applying schema changes by producing migration plans that use PostgreSQL's native online operations to minimize downtime and avoid locking. This allows developers to manage database schema evolution declaratively and with reduced risk.
Database administrators, backend engineers, and DevOps teams who manage PostgreSQL databases and need to apply schema changes with minimal disruption. It's particularly useful for teams practicing declarative infrastructure and continuous deployment.
Developers choose pg-schema-diff because it generates migration plans that prioritize safety and minimal downtime by leveraging PostgreSQL's built-in online operations. Its hazard warning system and plan validation provide confidence, reducing the risk of production incidents during schema migrations.
Go library for diffing Postgres schemas and generating SQL migrations
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Builds new indexes before dropping old ones using concurrent operations, preventing query performance degradation during migrations, as demonstrated in the index replacement example.
Adds constraints as NOT VALID before validation to avoid long access-exclusive locks, shown in the NOT NULL constraint creation example with temporary check constraints.
Allows defining desired schema in plain DDL and automatically generates migration plans, enabling teams to manage schema changes safely and efficiently.
Validates migration plans against a temporary database before execution, reducing the risk of production incidents by catching errors early.
Offers strong support for partitioned tables, which is essential for large-scale databases handling complex data structures.
Only supports enums for type changes; other type modifications like altering column types are unsupported, which can hinder schema evolution for complex data models.
Treats renaming of database objects as drops and adds, leading to potential data loss or unnecessary operations, as admitted in the README under unsupported migrations.
The project is in early stages with limited cycles for code contributions, indicating potential instability or slower feature development compared to established tools.
Lacks support for stateful online migration techniques like shadow tables, which might be necessary for zero-downtime changes involving data transformations.