Skip to the content
Know your tech before you buy it. Makers: get listed from $49/mo

sqldef

github.com

  • Free plan
  • Windows
  • macOS
  • Linux
  • Self-hosted
7.4 Club score Visit github.com

What sqldef is

sqldef is a free command-line tool for managing relational database schema changes with SQL DDLs. Keep a SQL file describing the schema you want; sqldef compares it with the current database and can generate and apply the changes. It lists support for MySQL, MariaDB, TiDB, PostgreSQL, SQL Server, and SQLite3. You can export the current schema and use a dry run to preview migrations before applying them. It can also compare two SQL files without a database connection, for validation, CI/CD workflows, or migration script generation. The project describes repeated runs as safe: if the database already matches the desired schema, another run shows 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. Platforms listed include Linux, macOS, Windows, and self-hosted; Debian packages are not currently available. The free tool's source files use the MIT License, while its parser uses Apache License 2.0.

Who it suits

sqldef suits developers and teams managing SQL schema changes across its supported relational databases. Its offline comparison and GitHub Action integration may also suit CI/CD workflows.

Good to know, and what to watch

  • Supports six listed database systems.
  • Previews migrations with dry-run.
  • Compares SQL files without a database connection.
  • Single-binary tools have no dependencies.
  • Debian packages are not currently available.
  • No free trial is listed.

sqldef

Free

Free plan

Getting started

  1. Open the sqldef GitHub repository
  2. Choose a binary, Docker image or listed Homebrew tap for your platform
  3. Create a SQL file containing the desired complete schema
  4. Connect sqldef to a supported database or prepare two SQL files for offline comparison
  5. Export the current schema and run a dry-run preview
  6. Apply the generated DDL changes

The Club's review

sqldef is a free command-line utility for managing relational-database structure with ordinary SQL. It is best for developers and operations teams who prefer declarative schema files and repeatable automation over a graphical migration workspace. Its broad engine coverage and offline workflow are compelling, provided your team is comfortable reviewing database-specific DDL.

Overview

You maintain one SQL file containing the complete schema you want. sqldef compares that desired state with the current database, generates the required DDL, and can apply it. Repeated execution is intended to be idempotent: once the database matches the file, subsequent runs report no changes. That is a practical safeguard for deployments and CI jobs, although teams still need their own approval and rollback discipline for destructive or high-impact changes.

The project covers MySQL, MariaDB, TiDB, PostgreSQL, SQL Server, and SQLite3. This multi-engine scope suits organizations with mixed relational infrastructure, but it does not turn SQL into a portable dialect; each target still requires an appropriate schema.

Key features

  • Declarative diffing: Generate and apply changes from the desired schema instead of hand-maintaining a chain of migration steps. This reduces bookkeeping for teams that can treat the schema file as the source of truth.
  • Preview and export: Export an existing schema and run a dry-run to inspect proposed DDL without executing it. That makes change review safer before a deployment reaches a live database.
  • Offline comparison: Compare two SQL files without a database connection. It is useful for schema validation, CI/CD checks, and producing migration scripts in environments where a database is unavailable.
  • Rename annotations: An @renamed annotation documents renames for tables, columns, indexes, and ENUM values. This helps the diff engine distinguish an intentional rename from a drop-and-create operation.
  • Automation packaging: Each database-specific tool is distributed as a single binary with no dependencies. Docker images and a GitHub Action for previewing schema changes provide practical integration points for pipelines.

The CLI approach is the central trade-off. SQL-literate teams gain transparent, scriptable workflows; users seeking visual modeling, guided editing, or a desktop administration surface should look elsewhere.

Pricing

sqldef — free: The open-source CLI is free to use, with the main project under the MIT License and its parser under Apache License 2.0. There is no paid tier or trial period to manage, so the product fits teams that can operate and support a command-line tool themselves. The trade-off is that there is no commercial plan promising bundled vendor support or a graphical interface.

Platforms

sqldef runs on Linux, macOS, Windows, and self-hosted environments. Linux users get prebuilt binaries and Docker images, but Debian packages are not currently provided, so installation may require choosing another distribution format. A Homebrew tap is available for mysqldef, psqldef, sqlite3def, and mssqldef on macOS. A release commit is marked with GitHub's verified signature and includes a release attestation asset, useful for teams that check provenance before adopting binaries.

Who it's for

Choose sqldef when developers, database engineers, or platform teams want SQL DDL in version control, repeatable desired-state reconciliation, and database-independent pipeline steps. Its offline mode is particularly suitable for pull-request validation and migration generation. It is a weaker fit for teams that rely on visual tools, need a packaged Debian installation, or want a vendor-managed support contract.

Pros and cons

  • Pros: Free and open source; supports six relational engines; idempotent runs reduce noise in repeat deployments; dry-run and offline comparison support controlled CI/CD workflows; single-binary distribution minimizes runtime dependencies.
  • Cons: The command-line, SQL-first workflow demands database expertise; SQL remains engine-specific despite multi-engine support; Linux users do not get Debian packages; operational support is centered on pull requests and GitHub Discussions rather than a commercial service.

Alternatives

For a broader comparison, see Database Schema Comparison Tools.

  • dbForge Studio for PostgreSQL is the better choice when you want a graphical PostgreSQL workspace, visual editing, and a free Express offering with a trial.
  • Skeema suits MySQL-oriented teams that want a freemium product with a free Community plan and a paid Plus tier.
  • Redgate SQL Provision is for organizations provisioning or masking large production-data volumes through capacity-based paid tiers.
  • SQL Delta is a paid Windows option for teams seeking a database comparison product from The Australian Software Company.
  • apgdiff is a free, MIT-licensed PostgreSQL schema-diff tool when PostgreSQL alone is sufficient.
  • pgquarrel is another free schema-diff choice, with BSD-3-Clause licensing and Linux, self-hosted, and Windows support.
  • SQL DXP is a paid Windows alternative from The Australian Software Company.
  • dbdiff is a free cross-platform database schema comparison option.

Verdict

sqldef is a strong choice for SQL-fluent teams that want a free, declarative, multi-engine schema workflow with dry-runs and CI-friendly offline checks. Look elsewhere if your priority is a visual interface, Debian-native Linux packaging, or commercial support rather than a lightweight CLI you operate yourself.

The verdict

sqldef offers a SQL-file-centered way to plan and apply schema changes, with both database-connected and offline workflows. Check its listed database support and Linux packaging details against your environment.

Questions people ask

Which databases does sqldef support?

It lists MySQL, MariaDB, TiDB, PostgreSQL, SQL Server and SQLite3.

Is sqldef free and open source?

Yes. The listed plan is free, and source files use the MIT License; the parser uses Apache License 2.0.

Can it preview migrations?

Yes. The workflow includes a dry-run mode that previews migrations without executing them.

Can sqldef work without a database connection?

Yes. Offline mode compares two SQL files for schema validation, CI/CD use or migration-script generation.

What platforms are listed?

Linux, macOS, Windows and self-hosted use are listed. Linux has prebuilt binaries and Docker images, and macOS has a Homebrew tap for several tools.

What the maker publishes

Build and dependencies
The project says each database tool is distributed as a single binary with no dependencies. source
Databases
The project lists support for MySQL, MariaDB, TiDB, PostgreSQL, SQL Server, and SQLite3. source
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. source
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. source
Integrations
The project links to Docker images on Docker Hub and a GitHub Action that previews database schema changes. source
Intended users
The project describes sqldef as a tool for managing schema changes across supported relational databases using SQL. source
License
The repository says source files are distributed under the MIT License, with the parser under Apache License 2.0. source
Linux availability
The README provides prebuilt Linux binaries and Docker images and says Debian packages are not currently available. source
macOS availability
The README says a Homebrew tap is available for mysqldef, psqldef, sqlite3def, and mssqldef. source
Offline mode
sqldef can compare two SQL files without connecting to a database, for schema validation, CI/CD, and migration script generation. source
Preview and export
The command workflow includes exporting the current schema and using dry-run to preview migrations without executing them. source
Purpose
sqldef is a CLI tool for diffing SQL schemas and managing relational database migrations with regular SQL DDLs. source
Rename support
The README documents renaming tables, columns, indexes, and ENUM values using an @renamed annotation. source
Security and provenance
The release page marks the release commit as signed with GitHub’s verified signature and displays a release attestation asset. source
Support and community
The README directs feature requests to pull requests or GitHub Discussions. source

Checked against the maker's pages on 30 Sept 2026.