public void MigrateUp(bool useAutomaticTransactionManagement) { var migrations = MigrationLoader.LoadMigrations(); using (IMigrationScope scope = _migrationScopeHandler.CreateOrWrapMigrationScope(useAutomaticTransactionManagement && TransactionPerSession)) { ApplyMaintenance(MigrationStage.BeforeAll, useAutomaticTransactionManagement); foreach (var pair in migrations) { ApplyMaintenance(MigrationStage.BeforeEach, useAutomaticTransactionManagement); ApplyMigrationUp(pair.Value, useAutomaticTransactionManagement && pair.Value.TransactionBehavior == TransactionBehavior.Default); ApplyMaintenance(MigrationStage.AfterEach, useAutomaticTransactionManagement); } ApplyMaintenance(MigrationStage.BeforeProfiles, useAutomaticTransactionManagement); ApplyProfiles(); ApplyMaintenance(MigrationStage.AfterAll, useAutomaticTransactionManagement); scope.Complete(); } VersionLoader.LoadVersionInfo(); }
public void MigrateUp(bool useAutomaticTransactionManagement) { var migrations = MigrationLoader.LoadMigrations(); using (IMigrationScope scope = _migrationScopeHandler.CreateOrWrapMigrationScope(useAutomaticTransactionManagement && TransactionPerSession)) { try { ApplyMaintenance(MigrationStage.BeforeAll, useAutomaticTransactionManagement); foreach (var pair in migrations) { ApplyMaintenance(MigrationStage.BeforeEach, useAutomaticTransactionManagement); ApplyMigrationUp(pair.Value, useAutomaticTransactionManagement && pair.Value.TransactionBehavior == TransactionBehavior.Default); ApplyMaintenance(MigrationStage.AfterEach, useAutomaticTransactionManagement); } ApplyMaintenance(MigrationStage.BeforeProfiles, useAutomaticTransactionManagement); ApplyProfiles(); ApplyMaintenance(MigrationStage.AfterAll, useAutomaticTransactionManagement); scope.Complete(); } catch { if (scope.IsActive) { scope.Cancel(); // SQLAnywhere needs explicit call to rollback transaction } throw; } } VersionLoader.LoadVersionInfo(); }