terradb

Declarative schema management for PostgreSQL and SQLite

A TypeScript CLI that diffs CREATE statements against a live PostgreSQL or SQLite database and generates the ALTER, DROP and CREATE statements between them, from tables and partitions to routines, policies, roles and grants, each tagged with its order and risk.

Trade-offs

  • pull writes an existing database's schema as a file, then plans that file against the same database and writes nothing unless the plan is empty, so the baseline is verified.
  • Destructive statements are flagged in every plan, and --strict refuses to apply them with a stable STRICT_MODE_ERROR, from drops down to weakened view or role options.
  • Concurrent index work on PostgreSQL must be one standalone statement: mixed plans fail before anything runs, and every other statement joins one transaction.

Q&A4

Transactional statements run atomically, so a failure leaves the database in its previous consistent state; for concurrent statements the exact failing statement is reported, and a failed concurrent index build removes only the invalid index it created.

Reviews

Loading reviews

    More from @elitan

    All 2 →
    • VeloSelf-hosted control plane for Postgres backups, PITR and dev branches

    More in Migrations

    See all 7 →
    • PaganelData migration engine that verifies the destination down to the row
    • MigrationPilotPostgreSQL migration linter that blocks unsafe DDL before merge
    • pistachioDeclarative PostgreSQL schema management with a plan and apply workflow
    • FlydbVersioned database migrations with a local GUI, a CLI and agent hand-off
    • pgmoldPostgreSQL schema-as-code in plain SQL, with safety linting and drift checks
    • dbconformFinds and repairs drift between a SQL database and its SQLAlchemy models

    More in Postgres

    See all 25 →
    • SupermetryCookie-free web and product analytics on one Go binary and PostgreSQL
    • arbiterPostgreSQL job queue for Haskell, with no broker and no leader
    • StreambedPostgres-to-Iceberg CDC engine with a built-in Postgres wire query server
    • go-ledgerMulti-tenant double-entry payment ledger API in Go, built in public
    • RRQClosed-loop payment ledger on sharded Postgres with a Kafka outbox
    • pgledgerDouble-entry ledger implemented entirely in PostgreSQL functions and views

    More in SQLite

    See all 22 →
    • MnemosyneLocal-first agent memory in one SQLite file, with evidence on every record
    • FusionalySelf-hosted web analytics in one SQLite file
    • SNKVEmbedded key-value store built directly on SQLite's B-tree
    • musqlSQLite-compatible SQL engine on columnar storage and a JIT
    • ForemergeCoordination protocol that catches intent conflicts between coding agents
    • roam-codeLocal code index and checks that coding agents can query