Skip to content

AzureDbUp is a cross-platform console application that updates Azure SQL databases using DbUp

Notifications You must be signed in to change notification settings

TroyWitthoeft/AzureDbUp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure DbUp Logo

Overview

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.

Azure DbUp demo

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.

Sql Folders

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.

image

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.

Try it locally

  • 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!

Databases supported

Azure DbUp currently supports: Azure Sql, MySql, PostgreSQL, CockoachDB

Azure DbUp databases

Support for other databases is planned.

Contributing

This is a small project. All feedback is welcome and every commit is a gift. Pull requests are welcome and encouraged!

Project Dependencies

  • 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.

License

MIT

About

AzureDbUp is a cross-platform console application that updates Azure SQL databases using DbUp

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages