Database.Versioning

Database versioning is easy now!

Build status codecov NuGet NuGet

About

This project provides very straightforward and elegant way to keep track on database schema and data changes. There is no need to execute all database scripts each time you are updating a product. You don’t need to re-run all scripts with every update. The project is designed to automatically detect your current version and run only new scripts with no need to re-run all previous. This is a very easy, suitable and fast option that might significantly reduce deployment time, so you don’t need to put additional efforts to update your app and can do it quickly without major impact on your customers.

How to

After package is installed you will find the new folder called Scripts in the solution. There are two files inside the folder: create.sql and update.sql. create.sql contains script that creates empty database and table with database version information. update.sql has dummy example how to write version changes.

Note: Before running the application go to script files preferences and change compile type to Content.

Rules and suggestions for successful versioning

Example

In the application startup on in the installer or whenewer you need you can perform database update like this:

var connectionString = $"Data Source=(local);Initial Catalog={databaseName};Integrated Security=True";
var databaseManager = new DatabaseManager(connectionString);
if (!databaseManager.Exists()) {
    databaseManager.Create();
}
databaseManager.Update();

Enjoy!