AzureDbUp is a lightweight, open-source, cross-platform, cross-database-engine application that runs sql migration scripts to keep your databases in sync and up to date. AzureDbUp wraps the DbUp project in a console application that exposes the DbUp API as command line parameters. This application was built to help get your database changes under source control where they can be rapidly reviewed, audited, and deployed.
To get started, clone this repository to your CI/CD system of choice and have your developers commit sql change scripts files into the sql folders. Then, configure your pipeline to build this repository and execute the built application. When executed, AzureDbUp will make a test connection to your database, and then execute any new sql scripts that have been committed to the repository.
To automate the interactivity seen above, use command line parameters.
dotnet AzureDbUp.dll --conn-string "Server=tcp:my-example-server.database.windows.net,1433;Initial Catalog=my-example-database" --db-engine "sqlserver" --auth-mode "azure"
Through DbUp, AzureDbUp inherits support for multiple database engines such as PostgreSQL, MySql, along with Sql Server. AzureDbUp also supports using Azure Active Directory tokens as part of your connection string to help keep database credentials out of your code repository and CI/CD system. Please compare AzureDbUp to products like RedGate ReadyRoll, Liquibase, and Flyway.
AzureDbUp tracks which new sql files to run using a DbUp feature called journaling. Sql files are executed in alphanumeric order, starting with foldername, and then files inside. Out of the box this repository has three sql folders. Sql files in the prescripts and subscripts folder are always ran and their runs are not logged to the DbUp [SchemaVersions]
table.
The folder run behavior can be adjusted by adding/removing the run-always
or no-log
keywords from the folder name. These keyword control the DbUp RunAlways and NullJournal behavior. RunAlways folders can be useful if you want to always apply certain scripts. Typically these are idempotent scripts that drop and create things like functions, views, procedures, and permissions. Or, database maintenance such as rebuilding indices, etc.
- Prereq: Download and install dotnet core.
- Download the latest release of AzureDbUp. Unzip the files to a folder.
- Edit and save your .sql scripts in the sql folder.
- Launch a terminal and call
dotnet AzureDbUp.dll
- Enter a connection string, choose your options, and let it rip!
Azure DbUp currently supports: Azure Sql, MySql, PostgreSQL, CockoachDB
Support for other databases is planned.
This is a small project. All feedback is welcome and every commit is a gift. Pull requests are welcome and encouraged!
- This application was developed in VS Code and targets the .NET 5.0 framework.
- This application uses the DbUp library to manage database updates.
- This application uses Spectre Console to beautify the console output.
- This application uses System CommandLine DragonFruit library to simplify command line argument parsing.
- This application uses the Azure Identity library for authentication and azure sql token retrieval.
This application uses Microsoft Graph library to walk and list the current users Azure AD security groups.