Badger Trek
Database migrations for SQL Server, Azure SQL, PostgreSQL, MySQL, MariaDB and SQLite that you can prove. Free, cross-platform, with real up and down.
SQL Server, PostgreSQL, MySQL, MariaDB and SQLite
One tool for SQL Server 2019 and later and Azure SQL, PostgreSQL 15 to 18, MySQL 8.4 and 9.7, MariaDB 10.11 to 12.3, and SQLite 3.26 and later. SQLite has its engine built in: a database file, nothing to install. SQLite · Convert between them
Named changes, no collisions
Changes have names, not version numbers. The plan file merges with git's union driver, so two developers adding changes the same day never collide.
Hash-certified
SHA-256 per change and a hash chain over the whole plan. Same head hash means byte-identical history on every machine and environment.
Real down, for free
Revert scripts are first-class. They are stored in the database at deploy time, so rollback works from any branch, even after the change is gone.
Environments built in
dev, test, prod with inheritance, protected environments, fix-forward production, and a database that remembers which environment owns it.
Every Entra ID flow
Browser and device code with MFA (cached between runs), managed identity, service principals, workload identity, Azure CLI, pipelines, plus SQL and Windows auth.
Always Encrypted keys
Scripts use the same key names everywhere; each environment brings its own column master keys. Badger Trek provisions and rotates them.
Variables that render
[calc_{env}] becomes [calc_test] in test. Built-ins, nested variables, per-environment values, and a hash of the SQL that actually ran.
Safe by default
A deploy lock for concurrent pipelines, transactional changes with verify scripts, a linter for each SQL dialect, drift detection, and edited-after-deploy detection.
One binary, any OS
Windows, macOS and Linux (x64 and Arm), or a .NET tool. No Java, no Perl, no sqlcmd. Connects through SSH bastions too.
How it works
A project is a folder with a trek.plan (the order), one folder per change with deploy.sql, revert.sql and an optional verify.sql, and a trek.yaml describing your environments.
db/
trek.yaml environments, authentication, variables, keys
trek.plan one change per line, in deploy order
changes/
create-customer/
deploy.sql up
revert.sql down
verify.sql proves the deploy worked (optional)
repeatable/ views, procedures, functions: re-applied when changed
environments/dev/ scripts that run only in dev (seed data)
trek add add-customer-email --requires create-customer
trek deploy -e test
trek status -e prod
trek revert --to create-customer -e test
Every deploy records the script hashes, who ran it, where, and a hash chain that certifies the order. trek status tells you when a database is certified: it received exactly the plan, in order, byte for byte.
Why another migration tool?
Flyway charges for undo and collides when two branches pick the same version number. DbUp only goes up and ignores edited scripts. SSDT computes a different script on each machine. Sqitch has the right model but a Perl install and weak SQL Server support. Badger Trek keeps the best ideas of each and fixes the gaps. See the comparison →
Documentation · Example scripts · Download · What's new · Source on GitHub