示例#1
0
        public static MigrationSet MakePlan(IDatabase database, ChangeGoal spec, params IMigrationLoader[] migrationLoaders)
        {
            var targetVersion = FindTrueTargetVersion(spec.TargetVersion, migrationLoaders);

            User.Notify(DescribePlan(spec.CurrentVersion, targetVersion));
            var plan = PlanToGetFromCurrentToTarget(spec, targetVersion);

            return(new MigrationSet(plan, database, migrationLoaders));
        }
示例#2
0
 private static ChangePlan PlanToGetFromCurrentToTarget(ChangeGoal spec, int targetVersion)
 {
     if (targetVersion >= spec.CurrentVersion)
     {
         var firstMigrationToApply = spec.CurrentVersion + 1;
         return(new ChangePlan(Do.Apply,
                               Enumerable.Range(firstMigrationToApply, targetVersion - firstMigrationToApply + 1)));
     }
     else
     {
         var firstMigrationToApply = spec.CurrentVersion;
         return(new ChangePlan(Do.Unapply,
                               Enumerable.Range(targetVersion + 1, firstMigrationToApply - targetVersion).Reverse()));
     }
 }
示例#3
0
 public ChangePlanner(IDatabase database, ChangeGoal request)
 {
     _database = database;
     _request  = request;
 }