Esempio n. 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);
        }
Esempio n. 2
0
        public void Run(string seedName, string param = null, string migrationGroup = null)
        {
            Type seedType = MigrationFinder.FindSeed(_targetAssembly, seedName);

            Log.Info("Starting seed migration");
            Log.Info("Migration group: " + VersionRepository.GetMigrationGroup(migrationGroup));
            Log.Info(String.Format("Applying Seed -> [{0}]", seedName));

            var migration = (SeedMigration)Activator.CreateInstance(seedType);

            migration.SetDataClient(_dataClient);
            migration.Up(param);
            _dataClient.Commit();
        }
Esempio n. 3
0
 public void Info(object message)
 {
     _logger.Info(message);
     AddComment(message);
 }
Esempio n. 4
0
 protected void Log(string msg, params object[] args)
 {
     _log.Info(String.Format(msg, args));
 }