Skip to content

Quick Start

-- schema.sql
CREATE TABLE users (
id BIGINT PRIMARY KEY,
email TEXT NOT NULL,
created_at TIMESTAMP DEFAULT now()
);
Terminal window
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb

This compares your SQL file against the live database and shows the migration plan.

Terminal window
pgmold apply -s sql:schema.sql -d postgres://localhost/mydb

All operations run in a single transaction. If anything fails, nothing changes.

Terminal window
pgmold drift -s sql:schema.sql -d postgres://localhost/mydb --json

Returns exit code 1 if the database has drifted from your schema files. Use this in CI.