Quick start
From an empty folder to a certified database in ten minutes.
You need a SQL Server you can reach. A local container works:
docker run -d --name sql -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD="Your_str0ng_password" -p 1433:1433 mcr.microsoft.com/mssql/server:2022-latest
export TREK_LOCAL_PASSWORD="Your_str0ng_password"
1. Create a project
trek init -C db
cd db
This writes trek.yaml, an empty trek.plan, the changes/, repeatable/ and environments/ folders, and a .gitattributes rule that lets git merge the plan. Edit the local environment in trek.yaml so database: names a database that exists.
2. Add a change
trek add create-customer
changes/create-customer/deploy.sqlCREATE TABLE dbo.Customer (
Id int IDENTITY NOT NULL CONSTRAINT PK_Customer PRIMARY KEY,
Name nvarchar(200) NOT NULL
);
changes/create-customer/revert.sqlDROP TABLE dbo.Customer;
changes/create-customer/verify.sqlIF OBJECT_ID(N'dbo.Customer', N'U') IS NULL THROW 50000, N'Customer missing', 1;
3. Check, then deploy
trek plan check # no database needed: plan, folders, lint, variables
trek doctor # can we sign in and connect?
trek deploy --dry-run
trek deploy
4. Look at the result
trek status
environment local
target sqlserver://localhost:1433/App
+ create-customer 2026-11-03 18:03Z you
database head 0e21ef9c72f3
plan head 0e21ef9c72f3
up to date and certified: database history is identical to the plan.
5. Change your mind
trek add add-customer-email --requires create-customer
# write deploy.sql / revert.sql
trek deploy
trek revert --last 1 # runs the revert.sql stored at deploy time
trek deploy # and forward again
trek log # who did what, when, from where
Next
- Add a test and a production environment: Environments.
- Sign in with Entra ID: Authentication.
- Commit
db/to git and addtrek plan checkto CI: CI/CD.