The schema is the source of truth
A DB-X schema is a JSX component. Apply it to a managed Postgres via <DatabaseTarget>, or stand up a fresh container in a single Compose stack via <Service> — the same schema, two distributions.
- Schema
- Managed DB
- Local (Docker)
/** @jsxImportSource @db-x/runtime */
import { Column, Postgres, Table } from '@db-x/postgres-library';
// The single source of truth. Both runtimes below apply this exact tree.
export const schema = (
<Postgres name="todos-db">
<Table name="todos">
<Column name="id" type="serial" primaryKey />
<Column name="title" type="text" notNull />
<Column name="done" type="boolean" notNull default="false" />
</Table>
</Postgres>
);
/** @jsxImportSource @db-x/runtime */
import { DatabaseTarget } from '@db-x/runtime';
import { schema } from './schema';
// Production: point at an existing RDS / Cloud SQL / Supabase URL.
export default (
<DatabaseTarget url={process.env.DATABASE_URL!}>
{schema}
</DatabaseTarget>
);
/** @jsxImportSource @infra-x/runtime */
import { DockerCompose, Service } from '@infra-x/docker-library';
import { schema } from './schema';
// Local dev / CI: stand Postgres up in Compose, then apply the schema.
export default (
<DockerCompose>
<Service name="db" image="postgres:16-alpine">
{schema}
</Service>
</DockerCompose>
);
Time Machine
Snapshot before every apply. Restore in one command. Diff any two points in time. Pg_dump for self-hosted, RDS / Cloud SQL APIs for managed.
Shadow-DB preview
Spin an ephemeral copy, dry-run the DDL, report timings and lock contention before the real apply. Find the bad migration on staging, not at 2am.
AI review built in
An MCP server exposes describe, explain, graph, and preview as tools. Claude Code / Cursor / Cline can review the change against the live schema before you ship.
Stays out of your ORM
DB-X owns deployment, not your query layer. Keep Drizzle, Prisma, sqlc, or whatever — DB-X exports types so the two stay in sync.
Jump in
Install
Get the db-x binary and @db-x/postgres-library on your machine.
Quickstart with Docker
Stand up Postgres in Compose and apply your first schema.
Quickstart with a managed DB
Point DB-X at an existing RDS, Cloud SQL, or Supabase URL.
Time Machine
How snapshots, restore, and diff work across managed providers.
AI review
Wire the MCP server into Claude Code or Cursor.
Roadmap
What is shipped, in progress, and planned next.