Quick Start
1. Create a schema file
Section titled “1. Create a schema file”-- schema.sqlCREATE TABLE users ( id BIGINT PRIMARY KEY, email TEXT NOT NULL, created_at TIMESTAMP DEFAULT now());2. See what would change
Section titled “2. See what would change”pgmold plan -s sql:schema.sql -d postgres://localhost/mydbThis compares your SQL file against the live database and shows the migration plan.
3. Apply the migration
Section titled “3. Apply the migration”pgmold apply -s sql:schema.sql -d postgres://localhost/mydbAll operations run in a single transaction. If anything fails, nothing changes.
4. Detect drift
Section titled “4. Detect drift”pgmold drift -s sql:schema.sql -d postgres://localhost/mydb --jsonReturns exit code 1 if the database has drifted from your schema files. Use this in CI.
Next steps
Section titled “Next steps”- Multi-file schemas — organize your schema across directories
- Filtering — include/exclude objects by name or type
- CI/CD integration — add schema checks to your pipeline
- Adopting pgmold — baseline an existing database