Prevent catastrophic PostgreSQL migration locks with ease.
Project details
Safe-migrate is a CI/CD infrastructure tool designed to identify risky PostgreSQL migrations before they hit production. By parsing SQL and simulating schema changes, it ensures that potential issues are spotted early on, safeguarding your database from catastrophic locks. Compatible with PostgreSQL 14–18 and simple to install.
safe-migrate is an advanced Continuous Integration/Continuous Deployment (CI/CD) infrastructure tool designed to mitigate the risks associated with PostgreSQL database migrations. By intelligently analyzing and simulating SQL schema changes before they reach production, safe-migrate helps prevent catastrophic locking issues in live environments.
safe-migrate is compatible with PostgreSQL versions 14 to 18, providing broad coverage for various project requirements.
Set up and run safe-migrate effortlessly with the following commands:
export DATABASE_URL='postgres://readonly_user@localhost:5432/app'
safe-migrate sync
safe-migrate lint-chain --dir migrations
This will initiate syncing and perform checks on your migration files.
By creating a safe-migrate-baseline environment in GitHub, users can automate monitoring and initialization tasks. This includes generating a trusted baseline for migration assessments, necessary for maintaining database integrity in CI workflows.
safe-migrate provides categorized results based on the severity of the findings. Each conclusion contributes to a better understanding of the migration's impact:
| Tier | Description | Exit Code |
|---|---|---|
Tier1 | Blocking safety issue | Exit 2 |
Tier2 | Requires review | Exit 0 |
Tier3 | Informational guidance | Exit 0 |
Users can customize their settings in a safe-migrate.toml file to better suit their project requirements. This includes rules for handling specific migration scenarios, thresholds for operation safety, and more.
For those interested in integrating safe-migrate within Rust applications, the API allows for seamless analysis with existing baseline data:
use safe_migrate::api::{self, Baseline, Config};
use std::path::Path;
let config = Config::load_from_file(Path::new("safe-migrate.toml"))?;
let baseline = Baseline::load_optional(Path::new(".safe-migrate.cache"), &config)?;
let outcome = api::analyze(
&config,
"2026-09-05_add_index.sql",
"CREATE INDEX ...",
&baseline,
)?;
if outcome.should_halt() {
eprintln!("{}", outcome.markdown());
}
safe-migrate stands out as a crucial tool for developers and database administrators looking to ensure a smooth migration process within PostgreSQL. By eliminating the risks of catastrophic locks and fostering an environment of careful analysis, it empowers teams to deploy changes with confidence.
Comments
0Start the conversation
Share the first comment.