Open source

The database toolkit built for PostgreSQL.

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

One tool, complete workflow

Migrations

Pure SQL with up/down sections. Timestamp-based ordering. Baseline support for brownfield adoption.

$ pgcrate up

Seeds

Load reference data from CSV or SQL. Type inference. Diff against database state.

$ pgcrate seed run

Models

SQL transformations with DAG ordering. Views, tables, incrementals. Built-in data tests.

$ pgcrate model run

Introspection

Deep table inspection with constraints, indexes, RLS policies. Role and grant inspection.

$ pgcrate describe users

Snapshots

Save and restore database state. Profile-based selective dumps. Great for testing.

$ pgcrate snapshot save dev

Anonymization

Export production data safely with TOML-based rules. Mask emails, fake names, redact PII.

$ pgcrate anonymize dump

No framework required

Pure SQL migrations

No DSL. No magic. Just SQL you already know. Write your schema changes in plain SQL with up/down sections.

  • Timestamp-based ordering
  • Baseline for brownfield adoption
  • Generate from existing database
20250101_create_users.sql
-- up
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    email TEXT UNIQUE NOT NULL,
    created_at TIMESTAMPTZ DEFAULT now()
);

-- down
DROP TABLE users;
models/marts/user_stats.sql
-- 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

SQL models with DAG ordering

Define SQL transformations with dependency tracking. pgcrate runs them in the right order, every time.

  • Views, tables, and incrementals
  • Built-in data tests
  • Auto-generated documentation

Understand your database

Deep introspection

See everything about your tables, roles, and permissions. Compare schemas across environments. Debug RLS policies.

  • Table structure, indexes, constraints
  • RLS policies and grants
  • Schema diff between databases
pgcrate describe users
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

Built for CI/CD

JSON output on every command. Meaningful exit codes. Production safeguards that prevent accidents.

  • --json flag on all commands
  • Exit codes: 0=ok, 1=action needed, 2=error
  • --yes required for destructive ops
ci.yml
# Check migration status
pgcrate status --json

# Run health checks
pgcrate doctor --json

# Apply migrations
pgcrate up --json