This project is read-only.

Project Description

This tool created as GUI for FluentMigrator Framework with few additional features:
1. Database backup creation and restoring from local backup file
2. Execution scripts from folder
3. Checking current database name
4. Several migration types

Main Window


How to use it

1. Download latest source
2. Open solution in Visual Studio
3. Go to project Migrations, Default folder
4. Add new file with public class based from Migration

using FluentMigrator;
namespace Migrations.Default
{
    [Migration(1, "Author: AuthorName; Description")]
    public class Migration_1: Migration
    {
        public override void Up()
        {
           // Migration Up code here
        }
        public override void Down()
        {
           // Migration Down code here
        }
    }
}

5. Compile and run application
6. Enter database host, login and password and click connect
7. Select Update To latest Version Operation Type
8. Select database in combo box
9. Click Do Job button
10. Check log

Several migration types for different databases

You can use this tool for migrate databases with different schema.
1. Go to Migrations project
2. Create new folder like "MySecondDatabase"
3. Create file with migration class based from Migration in namespace Migrations.MySecondDatabase

using FluentMigrator;
namespace Migrations.MySecondDatabase
{
    [Migration(1, "Author: AuthorName; Description")]
    public class Migration_1: Migration
    {
        public override void Up()
        {
           // Migration Up code here
        }
        public override void Down()
        {
           // Migration Down code here
        }
    }
}

4. Add new migration namespace in config MigrationNamespaces.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <MigrationNamespaces>
    <MigrationNamespace Name="Default" Path="Migrations.Default"/>
    <MigrationNamespace Name="My Second Database" Path="Migrations.MySecondDatabase"/>
  </MigrationNamespaces>
</configuration>

5. Compile and run Application
6. Select My Second Database from combo box

How to write migrations

1. Use can use FluentFramework API expressions like this

Create.Table("Users")
    .WithIdColumn()
    .WithColumn("Name").AsString().NotNullable();

2. Use can execute sql command

Execute.Sql("DELETE TABLE Users");

For more detail information please see FluentMigrator documentation https://github.com/schambers/fluentmigrator/wiki/Fluent-Interface

Bulk Script Execution

If you have many SQL scripts that should by applied as migration, you can execute them all by one command:

ScriptExecutor.ExecuteScriptsFromFolder("FOLDER_NAME" ,Execute);

Where FOLDER_NAME - name of folder with SQL scripts.




How to check database name

1. If you want to apply SQL script only for some specific database you can check it like this:

if (ScriptExecutor.GetDatabaseName(this) == "MyDatabase")



My other activity
1. UI Exception Handler: https://uiexceptionhandler.codeplex.com/
2. Simple and Free Profiler for Entity Framework: http://ef-logger.com/
3. My articles at russian IT site: http://habrahabr.ru/users/Diaver/topics/

Last edited May 7, 2014 at 3:06 PM by Diaver, version 14