public void Migrate(int startAfterVersion, int endVersion)
{
//Each migration should be done separately because changes to DDL does not support rollback.
var stepsToRun = endVersion - startAfterVersion;
startAfterVersion++;
if (stepsToRun > 0 && this.OnDbMigrationStarted != null)
this.OnDbMigrationStarted(this, new DBMigratorEventArgs((uint)startAfterVersion, (uint)startAfterVersion, (uint)endVersion));
for (int i = startAfterVersion; i <= endVersion; i++)
{
try
{
_connection.ExecuteSql(GetMigrationSql(i - 1, i).ToArray());
}
catch (Exception ex)
{
if (this.OnDbMigrationException != null)
this.OnDbMigrationException(this, new DBMigratorEventArgs((uint)startAfterVersion, (uint)i, (uint)endVersion));
throw ex;
}
SetCurrentVersion(i);
if (this.OnDbMigrationProgress != null)
this.OnDbMigrationProgress(this, new DBMigratorEventArgs((uint)startAfterVersion, (uint)i, (uint)endVersion));
}
if (stepsToRun > 0 && this.OnDbMigrationCompleted != null)
this.OnDbMigrationCompleted(this, new DBMigratorEventArgs((uint)startAfterVersion, (uint)endVersion, (uint)endVersion));
}