# sqldef/sqldef

Idempotent schema management for MySQL, PostgreSQL, SQLite, and SQL Server

Repository: https://github.com/sqldef/sqldef
Canonical: https://ross.abutalabs.com/products/sqldef
Homepage: https://sqldef.github.io
Language: Go
License: NOASSERTION
License Family: other
Topics: mysql, postgresql, schema-changes, mssql, sqlite3, declarative-migrations, sqldef, database-migrations, mariadb
Last push: 2026-08-25T13:43:18+00:00

## Health v2 (maintenance only)
Score: 95/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 99, release rhythm 86, longevity 100
- inputs: {"age_days": 2931, "days_push": 8, "days_rel": 14, "gap_med": 1, "n_releases_24m": 150}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3146, forks 243 (observed 2026-08-28T04:07:46.005531+00:00)

## What it is
sqldef is a single-binary CLI tool for idempotent, declarative database schema management using plain SQL DDL files. It diffs the desired schema against the current database schema and generates the migrations needed to reach the desired state, with per-database commands for MySQL/MariaDB/TiDB, PostgreSQL, SQLite3, and SQL Server.

## Use cases
- manage database schema as a single SQL file
- generate migrations from desired schema instead of writing them by hand
- diff two SQL schema files offline in CI
- apply idempotent schema changes safe to run repeatedly
- export current database schema to SQL
- preview DDL changes with a dry run before applying
- validate that database schema matches the schema file in CI/CD

## When to choose
- you prefer plain SQL DDL over ORM or DSL-based migration tools
- you want declarative, idempotent schema management across MySQL, PostgreSQL, SQLite, and SQL Server
- you need a dependency-free single binary for schema drift detection in CI pipelines
- you want to generate up (and down) migration DDLs by diffing schema files

## When to avoid
- you need versioned, sequential migration files with rollback history
- your workflow depends on ORM-managed migrations (e.g., Rails, Django, Alembic)
- you use a database other than MySQL/MariaDB/TiDB, PostgreSQL, SQLite3, or SQL Server

## Facets
- artifact type: cli-tool
- maturity: active
- function: database, developer-tools, cli
- domain: databases, developer-tools
- platform: windows, cli, wasm
- tags: schema-migration, declarative-migrations, idempotent, mysql, postgresql, sqlite, sql-server, mariadb, tidb, ddl-diff, devops, linux, macos

## Member repositories
- sqldef/sqldef (main) score 95

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:46.005531+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:25:58.063821+00:00, confidence not recorded.
  - readme: https://github.com/sqldef/sqldef (fetched 2026-08-28T04:07:46.005531+00:00, sha e5eca30ecd9f)
  - homepage: https://sqldef.github.io (fetched 2026-08-29T09:40:33.969158+00:00, sha ceabe6390af0)
- Data as of 2026-08-30T08:39:29.467469+00:00.
