sqldef
What it is
sqldef is a free command-line tool for managing relational database schema changes with SQL DDLs. Users keep a SQL file representing the desired schema, and the tool compares it with the current database to generate and apply changes. Supported databases are MySQL, MariaDB, TiDB, PostgreSQL, SQL Server, and SQLite3. The workflow can export a current schema and run a dry-run preview before applying migrations. sqldef can also compare two SQL files without a database connection, for tasks such as schema validation, CI/CD, and migration-script creation. Repeating an operation is safe: if the database already matches the desired schema, another run reports no changes. Rename annotations are documented for tables, columns, indexes, and ENUM values. Each database tool is distributed as a single binary with no dependencies. Linux, macOS, Windows, and self-hosted availability are listed; Debian packages are not currently available. The project links Docker images and a GitHub Action for previewing schema changes. Source files use the MIT License, while the parser is under Apache License 2.0.
For and against
For
- Supports six listed database systems.
- Dry-run previews migrations before execution.
- SQL files can be compared offline.
- Tools are distributed as single binaries without dependencies.
- Repeated runs show no changes when schemas match.
Against
- Debian packages are not currently available.
- The parser uses a different license from source files.
The verdict
sqldef offers a SQL-based approach to schema migrations, with preview and offline comparison options. Check its database and platform support, including the stated Debian package limitation, against your workflow.
Who it suits
sqldef may suit developers and teams managing schema changes across its supported relational databases with SQL. Its offline file comparison and GitHub Action may also suit CI/CD workflows.
Plans and prices
sqldef
Open-source CLI tool · MIT license (parser is Apache 2.0)
Read 30 Sep 2026 · github.com
On the record
- Build and dependencies
- The project says each database tool is distributed as a single binary with no dependencies.github.com · read 30 Sep 2026
- Databases
- The project lists support for MySQL, MariaDB, TiDB, PostgreSQL, SQL Server, and SQLite3.sqldef.github.io · read 30 Sep 2026
- Declarative schemas
- Users maintain a SQL file with the complete desired schema, which sqldef compares with the current schema to generate and apply DDL changes.github.com · read 30 Sep 2026
- Idempotence
- The README says operations are safe to run multiple times and repeated runs show no changes when the database already matches the desired schema.github.com · read 30 Sep 2026
- Integrations
- The project links to Docker images on Docker Hub and a GitHub Action that previews database schema changes.github.com · read 30 Sep 2026
- Intended users
- The project describes sqldef as a tool for managing schema changes across supported relational databases using SQL.sqldef.github.io · read 30 Sep 2026
- License
- The repository says source files are distributed under the MIT License, with the parser under Apache License 2.0.github.com · read 30 Sep 2026
- Linux availability
- The README provides prebuilt Linux binaries and Docker images and says Debian packages are not currently available.github.com · read 30 Sep 2026
- macOS availability
- The README says a Homebrew tap is available for mysqldef, psqldef, sqlite3def, and mssqldef.github.com · read 30 Sep 2026
- Offline mode
- sqldef can compare two SQL files without connecting to a database, for schema validation, CI/CD, and migration script generation.github.com · read 30 Sep 2026
- Preview and export
- The command workflow includes exporting the current schema and using dry-run to preview migrations without executing them.github.com · read 30 Sep 2026
- Purpose
- sqldef is a CLI tool for diffing SQL schemas and managing relational database migrations with regular SQL DDLs.sqldef.github.io · read 30 Sep 2026
- Rename support
- The README documents renaming tables, columns, indexes, and ENUM values using an @renamed annotation.github.com · read 30 Sep 2026
- Security and provenance
- The release page marks the release commit as signed with GitHub’s verified signature and displays a release attestation asset.github.com · read 30 Sep 2026
- Support and community
- The README directs feature requests to pull requests or GitHub Discussions.github.com · read 30 Sep 2026
The review
sqldef is a free command-line tool for managing relational database schemas with SQL. It is best suited to developers and teams working across supported database engines who want a declarative, repeatable workflow. Its breadth and offline comparison are useful; its command-line focus is a poor fit for readers seeking a graphical schema editor.
Overview
Keep a SQL file that describes the schema you want, and sqldef compares it with the current database to generate and apply the required DDL changes. Rather than maintaining a sequence of migration steps, teams work from the desired end state. Repeated runs are designed to be idempotent: once the database matches the file, another run reports no changes. That makes the workflow suitable for repeatable deployments, though teams still need to decide how to review and approve changes before applying them.
Supported engines are MySQL, MariaDB, TiDB, PostgreSQL, SQL Server, and SQLite3. This makes sqldef a practical choice for teams handling more than one relational database, but it does not make their SQL interchangeable: each schema must still suit its target engine.
Key features
- Declarative schema comparison: sqldef derives DDL changes by comparing the desired schema with the current one. This reduces reliance on individually maintained migration steps, but favors teams comfortable treating SQL as the source of truth.
- Preview and export: Export the current schema and use dry-run to see proposed migrations without executing them. That provides a review step before changes reach a database, rather than requiring the first view of a migration to be its execution.
- Offline comparison: Compare two SQL files without a database connection. This supports schema validation, CI/CD checks, and migration-script generation when connecting to a live database is not appropriate.
- Rename annotations: An @renamed annotation documents intended renames for tables, columns, indexes, and ENUM values. This gives the tool a way to distinguish a rename from other schema differences.
- Lightweight distribution and integrations: Each database tool is distributed as a single binary with no dependencies. Docker images and a GitHub Action that previews schema changes provide options for containerized and CI/CD workflows.
Pricing
sqldef costs nothing. The free plan is the project’s open-source CLI tool, with source under the MIT License and the parser under Apache License 2.0. There is no paid tier or trial to weigh against it; the trade-off is that the product is a CLI workflow rather than a priced graphical package.
Platforms
sqldef supports Linux, macOS, Windows, and self-hosted use. Prebuilt Linux binaries and Docker images are available, but Debian packages are not currently available, which may make it a less convenient fit for teams that expect that installation format. On macOS, a Homebrew tap covers mysqldef, psqldef, sqlite3def, and mssqldef.
The release page marks the release commit with GitHub’s verified signature and includes a release attestation asset. Feature requests go through pull requests or GitHub Discussions.
Who it's for
Choose sqldef if your team is comfortable with SQL and the command line, wants schema changes expressed as a complete desired schema, or needs to compare SQL files as part of CI/CD. Its multi-engine support is particularly relevant when work spans several of the supported relational databases. Look elsewhere if your workflow depends on a graphical interface or Debian packages.
Pros and cons
- Pros: One declarative SQL workflow covers six relational database engines, while idempotent runs help make repeated deployments predictable.
- Pros: Dry-run previews and offline file comparison support review and validation without executing changes or connecting to a database.
- Pros: Single-binary distribution without dependencies keeps the tool’s runtime footprint simple.
- Cons: The CLI and SQL-centered workflow will not suit teams that want a visual schema editor.
- Cons: Debian packages are not available, and the macOS Homebrew tap covers four named tools rather than every database tool.
Alternatives
For a broader comparison, browse Database Schema Comparison Tools. If PostgreSQL work calls for a graphical tool with a free plan and free trial, consider dbForge Studio for PostgreSQL; its Express plan includes code completion, formatting, query history, a visual data editor, and data import and export, while sqldef is a free CLI focused on schema change management across engines.
Skeema is another freemium CLI option, with a free Community plan covering tables, stored procedures and functions, and 18 linter checks; choose it when those stated Community features are a better match. Its Plus plan is $124 a month, billed $124/month or, while sqldef has no paid plan.
For a free PostgreSQL schema-diff tool, apgdiff is a narrower alternative to sqldef’s six-engine scope. driftcurve is free and offers self-hosted, API, and web platforms, so consider it when those deployment options are the priority. pgquarrel is a free BSD-3-Clause-licensed option for readers comparing schema tools.
UserFolderMigrator is a free, Windows-only alternative. dbdiff is another free option with Linux, macOS, self-hosted, and Windows platforms. DBDiff is also free and cross-platform, and is described by its maker as an open-source project.
Verdict
sqldef is a strong choice for SQL-literate teams that want free, repeatable schema management across supported relational engines, especially when dry-run previews or offline CI/CD comparisons matter. Its main reason to choose is the declarative workflow paired with broad database support; its main reason to look elsewhere is the command-line and SQL-first approach, with Debian installation also a limitation for some Linux users.