One binary. Pure SQL. Migrations, seeds, models, snapshots, and deep introspection. No framework required.
cargo install pgcrate Rust not installed? brew install pgcrate coming soon.
Everything you need
Pure SQL with up/down sections. Timestamp-based ordering. Baseline support for brownfield adoption.
pgcrate up Load reference data from CSV or SQL. Type inference. Diff against database state.
pgcrate seed run SQL transformations with DAG ordering. Views, tables, incrementals. Built-in data tests.
pgcrate model run Deep table inspection with constraints, indexes, RLS policies. Role and grant inspection.
pgcrate describe users Save and restore database state. Profile-based selective dumps. Great for testing.
pgcrate snapshot save dev Export production data safely with TOML-based rules. Mask emails, fake names, redact PII.
pgcrate anonymize dump No framework required
No DSL. No magic. Just SQL you already know. Write your schema changes in plain SQL with up/down sections.
-- up
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMPTZ DEFAULT now()
);
-- down
DROP TABLE users; -- materialized: table
-- deps: staging.stg_users, staging.stg_orders
-- tests: not_null(user_id), unique(user_id)
SELECT
u.id AS user_id,
u.email,
COUNT(o.id) AS order_count,
SUM(o.total) AS lifetime_value
FROM staging.stg_users u
LEFT JOIN staging.stg_orders o ON u.id = o.user_id
GROUP BY u.id, u.email Transform your data
Define SQL transformations with dependency tracking. pgcrate runs them in the right order, every time.
Understand your database
See everything about your tables, roles, and permissions. Compare schemas across environments. Debug RLS policies.
Table: public.users
Columns:
id serial PRIMARY KEY
email text NOT NULL UNIQUE
created_at timestamptz DEFAULT now()
Indexes:
users_pkey PRIMARY KEY (id)
users_email_key UNIQUE (email)
RLS: enabled
tenant_isolation USING (tenant_id = current_tenant()) Production ready
JSON output on every command. Meaningful exit codes. Production safeguards that prevent accidents.
--json flag on all commands --yes required for destructive ops # Check migration status
pgcrate status --json
# Run health checks
pgcrate doctor --json
# Apply migrations
pgcrate up --json