A .NET Core Global Tool to deploy changes to SQL databases using DbUp.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
appveyor.yml
dotnet-db-migrate.sln
nuget_icon.png

README.md

dotnet-db-migrate

Build status NuGet NuGet

A .NET Core Global Tool to deploy changes to SQL databases using DbUp.

Installation

dotnet tool install -g dotnet-db-migrate

At this point you will probably have to add the global tools path to PATH variable. Global tools are installed to %USERPROFILE%\.dotnet\tools (Windows) or $HOME/.dotnet/tools (macOS/Linux). You can add the tools directory to yur PATH using one of the following commands.

Windows: setx PATH "$env:PATH;$env:USERPROFILE/.dotnet/tools" Linux/macOS: echo "export PATH=\"\$PATH:\$HOME/.dotnet/tools\"" >> ~/.bashrc or your terminal of choice.

You will need to restart your terminal.

Usage

Once installed, running dotnet db-migrate -h will print the following help information.

A tool to deploy changes to SQL databases.

Usage: db-migrate [arguments] [options]

Arguments:
  ConnectionString    Required. The connection details for a database.

Options:
  -h|--help           Show help information
  -p|--provider       Optional. The connection provider. Default: mssql
  -s|--scripts        Optional. The path to the migration scripts. Default: scripts/
  --ensure-db-exists  Optional. Create the database if it doesn't exist. Default: false

Example Usage

dotnet db-migrate "Server=localhost;Port=5432;Database=northwind;User Id=postgres;Password=password;" -p postgres -s src/scripts/Postgres --ensure-db-exists

Output

Master ConnectionString => Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=********
Created database northwind
Beginning database upgrade
Checking whether journal table exists..
Journal table does not exist
Executing Database Server script '201806172131-Create-Contacts.sql'
Checking whether journal table exists..
Creating the "schemaversions" table
The "schemaversions" table has been created
Upgrade successful
Success!

Currently only MS SQL Server and Postgres are supported, this is due to --ensure-db-exists flag and how DbUp creates databases.

Contributing

This is an open-source project. I request your participation through issues and pull requests!

License

dotnet-db-migrate is licensed under MIT. Refer to LICENSE for more information.