sqlanvil
Open source · Apache-2.0 · Dataform fork

Write the model once.
Strike it native for every warehouse.

SQLAnvil compiles SQLX models into idiomatic SQL — a real BigQuery MERGE, a real Postgres ON CONFLICT, never a lowest-common-denominator dialect — and runs, tests, and validates the whole graph from your CLI, your CI, or your coding agent.

$ npm install -g @sqlanvil/cli
definitions/daily_sales.sqlx
-- one incremental model, any warehouse
config {
  type: "incremental",
  uniqueKey: ["order_date"],
  assertions: { nonNull: ["revenue"] }
}

SELECT
  order_date,
  SUM(amount) AS revenue,
  COUNT(*)    AS orders
FROM ${ref("stg_orders")}
WHERE order_date > ${when(incremental(),
  `(SELECT MAX(order_date) FROM ${self()})`,
  `DATE '2020-01-01'`)}
GROUP BY order_date
-- idiomatic postgres: upsert on the unique key
INSERT INTO "analytics"."daily_sales"
  ("order_date", "revenue", "orders")
SELECT
  order_date,
  SUM(amount) AS revenue,
  COUNT(*)    AS orders
FROM "analytics"."stg_orders"
WHERE order_date >
  (SELECT MAX(order_date)
   FROM "analytics"."daily_sales")
GROUP BY order_date
ON CONFLICT ("order_date") DO UPDATE SET
  "revenue" = EXCLUDED."revenue",
  "orders"  = EXCLUDED."orders";

One codebase, four engines

Each adapter emits the SQL a DBA would write for that engine — never a translation layer.

POSTGRESQL

The first-class focus

Native partitioning, INSERT … ON CONFLICT upserts, btree/gin/gist/brin indexes, tablespaces, fillfactor — declared in config, compiled to idiomatic DDL.

SUPABASE

Everything Postgres, plus

RLS policies, Realtime publications, pgvector indexes, and Supabase Wrappers (FDW) — with session-pooler-aware connections out of the box.

BIGQUERY

Standard SQL, standard tools

Partitioning, clustering, labels, materialized views, MERGE-based incremental upserts — and free dry-run validation before anything executes.

MYSQL / MARIADB

One adapter, both engines

ON DUPLICATE KEY upserts, engine/charset/collation control, secondary indexes including FULLTEXT/SPATIAL, native partitioning, matview emulation.

Built for the agent-native era

Point any coding agent at a SQLAnvil repo and it already knows the dialect.

EVERY PROJECT

AGENTS.md, scaffolded

sqlanvil init writes a warehouse-tailored AGENTS.md (plus a CLAUDE.md bridge) into every project — read natively by Codex, Cursor, Gemini CLI, Claude Code, and 30+ tools.

ONE INSTALL

The Agent Skill

npx skills add SQLAnvil/agent-skills teaches any supporting agent the full authoring discipline — config blocks, ref() hygiene, the validate loop.

OPERATIONS

A remote MCP server

SQLAnvil Cloud exposes your runs over MCP: your agent lists failures, pulls full error context, and triggers workflows — no dashboard tab required.

SQLAnvil Cloud: CI your pipelines deserve

A hosted control plane — branch CI, schedules, and run history. You keep authoring in your own tools.

Open a pull request

A webhook dispatches a keyless runner — no GitHub Action to hand-wire.

Your workflow runs against a real branch

Cloud creates an ephemeral branch of your Supabase project and builds every model and assertion against it. Nothing touches production.

Pass or fail lands on the PR

A SQLAnvil CI check turns green or red, per-action SQL and errors are captured, and the branch is destroyed.

Zero credential custody.

Cloud never stores your database password — it brokers a short-lived, revocable authorization per run. Connect once via OAuth; revoke any time.

Leaving Dataform?

sqlanvil migrate-dataform converts an existing project in one command — move to Postgres or Supabase, or keep running against the BigQuery warehouse you already have (--target-warehouse bigquery swaps the tooling and leaves your SQL untouched). A migration report flags anything that needs a human.