示例#1
0
        private void RunMigrations(MigrationPlan migrationPlan)
        {
            if (NoWorkToDo(migrationPlan))
            {
                Log.Info("No migrations to perform");
                return;
            }
            Log.Info("Starting migrations");
            Log.Info("Current version is " + migrationPlan.CurrentVersion);
            Log.Info("Target version is " + migrationPlan.TargetVersion);
            Log.Info(String.Format("Migrate action is: {0} from {1} to {2}",
                                   (migrationPlan.IsUp ? "UP" : "DOWN"),
                                   migrationPlan.CurrentVersion,
                                   migrationPlan.TargetVersion));

            foreach (var step in migrationPlan.OrderedSteps)
            {
                var migrationInfo = step.MigrationInfo;
                try {
                    RunMigration(step);
                }
                catch (NotSupportedByDialect nse) {
                    HandleNotSupportedByDialectException(migrationInfo, nse);
                }
                catch (Exception ex) {
                    string errorMsg = String.Format("Error running migration {0}: {1}", migrationInfo.Name, ex);
                    Log.Error(errorMsg);
                    _dataClient.RollBack();
                    throw new MigrationException(errorMsg, ex);
                }
            }
            Log.Info("Done. Current version: " + migrationPlan.TargetVersion);
        }
示例#2
0
 public NotSupportedByDialect(string message, string functionName, string dialectName) : base(message)
 {
     FunctionName = functionName;
     DialectName  = dialectName;
     Log.Error(String.Format("Dataclient error: operation {0} not supported by {1}", functionName, dialectName));
 }
示例#3
0
 public void Error(object message)
 {
     _logger.Error(message);
     AddComment(message);
 }