Skip to main content

Introducing Formengine - The New Formbuilder, try for FREE formengine.io.

Database Versioning

Starting from version 13.0.0, Workflow Engine supports automatic migration, enabling the creation and updating of the database schema without manual script execution.

Workflow Engine migrations

To initiate Workflow Engine migrations, execute the RunMigrations method when configuring the WorkflowRuntime after adding the PersistentProvider. This method will create a database schema or update an existing one.

_runtime
.WithPersistenceProvider(provider)
.RunMigrations();

Custom Migrations

You can create custom migrations by creating a class that inherits from Migration and adding the Migration attribute with the migration order number.

info

To maintain migration order, start your migrations with the number 2_000_000.

For managing migrations, Fluent.Migrator is used. For more details on creating migrations, refer to the official documentation.

Migration List

You can retrieve a list of all registered migrations and a list of pending migrations using the WorkflowRuntime methods GetMigrationNames and GetUnappliedMigrationNames respectively. You can also retrieve the SQL script text by specifying the migration name.

var migrationNames = _runtime.GetMigrationNames().ToList();
migrationNames.ForEach(scriptName =>
{
Console.WriteLine($"Script: {scriptName}");
string sql = _runtime.GetMigrationSql(scriptName);
Console.WriteLine(sql);
});

Additionally, if your migrations utilize SQL scripts as embedded resources, you can also retrieve a list of your migrations along with Workflow Engine migrations. To achieve this, add the WorkflowEngineMigration attribute to your migrations with a reference to the resource.

[Migration(2000000)]
[WorkflowEngineMigration("WF.Sample.Business.Scripts.Initial.sql")]
public class Migration2000000Initial : Migration
{
public override void Up()
{
this.EmbeddedScript();
}

public override void Down()
{
}
}