dbsh 2.1.3
dotnet tool install --global dbsh --version 2.1.3
dotnet new tool-manifest
dotnet tool install --local dbsh --version 2.1.3
#tool dotnet:?package=dbsh&version=2.1.3
nuke :add-package dbsh --version 2.1.3
<div align="center">
<img src="./icon.png" alt="dbsh" width="120">
dbsh
Database migrations that ship.
A Flyway-style migration tool for PostgreSQL, SQL Server, MySQL, and SQLite.
<br>
Documentation · Report Bug · Request Feature
</div>
What is dbsh?
dbsh is a SQL-first database migration tool for .NET. You write plain .sql files, and dbsh tracks, validates, and applies them across environments — with built-in safety features for production use.
Why not Entity Framework migrations? EF migrations are tightly coupled to your application code and hard to control in production. dbsh keeps migrations as standalone SQL files that live in your repository, work with any language or framework, and give you full control over what runs and when.
Features
- SQL-first — Plain
.sqlfiles. No embedded DSL, no XML, no surprises. - Multi-database — PostgreSQL, SQL Server, MySQL, and SQLite. Switch providers without changing your workflow.
- Safe by design — Distributed locks, approval gates, deployment windows, and audit trails.
- CI-friendly — Every command supports
--jsonoutput and deterministic exit codes. - Works offline — Validate, plan, and scaffold without a database connection.
- Checksum integrity — SHA-256 checksums detect when previously-applied scripts are edited in place.
Quick Start
# Install (no .NET required)
curl -fsSL https://github.com/AzimMahmud/dbsh/releases/latest/download/install.sh | bash
# Scaffold a project
dbsh new --name MyApp --provider postgresql
# Create a migration
dbsh create --name CreateUsersTable --type schema
# Validate & preview
dbsh validate
dbsh plan
# Deploy
dbsh migrate -c "Host=localhost;Database=myapp;Username=postgres"
Installation
No .NET SDK or runtime required — the binary is self-contained.
# Linux / macOS
curl -fsSL https://github.com/AzimMahmud/dbsh/releases/latest/download/install.sh | bash
# Windows (PowerShell)
powershell -c "iwr -Uri https://github.com/AzimMahmud/dbsh/releases/latest/download/install.ps1 | iex"
# .NET global tool (requires .NET 10 SDK)
dotnet tool install --global dbsh
Manual Download
| Platform | Download |
|---|---|
| Windows x64 | dbsh-windows-x64.zip |
| Windows ARM64 | dbsh-windows-arm64.zip |
| Linux x64 | dbsh-linux-x64.tar.gz |
| Linux ARM64 | dbsh-linux-arm64.tar.gz |
| Linux musl x64 (Alpine) | dbsh-linux-musl-x64.tar.gz |
| macOS x64 | dbsh-macos-x64.tar.gz |
| macOS ARM64 | dbsh-macos-arm64.tar.gz |
Commands
| Command | Description | DB Required |
|---|---|---|
new |
Scaffold a complete project | No |
create |
Create a migration script | No |
validate |
Check scripts for errors | No |
plan |
Preview execution plan | No |
info |
Show configuration | No |
init |
Create tracking tables | Yes |
migrate |
Apply pending migrations | Yes |
status |
Show migration status | Yes |
rollback |
Undo migrations | Yes |
repair |
Fix failed migrations | Yes |
history |
View audit trail | Yes |
Run dbsh <command> --help for command-specific options.
Configuration
dbsh uses a two-tier JSON configuration:
// Database/Config/migration.json
{
"migration": {
"database": {
"provider": "postgresql",
"connectionString": "${DB_CONNECTION_STRING}"
},
"scripts": {
"path": "./Database/Migrations"
},
"execution": {
"batchSize": 10,
"stopOnFailure": true
}
}
}
Per-environment overrides in Database/Config/environments/<name>.json with ${VAR} expansion for secrets. See the Configuration Guide for details.
Supported Databases
| Provider | Version | Config Value |
|---|---|---|
| PostgreSQL | 12+ | postgresql |
| SQL Server | 2016+ | sqlserver |
| MySQL / MariaDB | 8+ / 10.5+ | mysql |
| SQLite | 3 | sqlite |
Documentation
Full documentation is available at dbsh.azim.me.
Building from Source
git clone https://github.com/AzimMahmud/dbsh.git
cd dbsh
dotnet build dbsh.slnx
dotnet test dbsh.slnx --filter "Category!=Integration"
Requires the .NET 10 SDK.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.