in Source/NuGetGallery.Operations/Tasks/RunMigrationsTask.cs [81:113]
private void RunMigrations(MigratorBase migrator)
{
// We only support UP right now.
// Find the target migration and collect everything between the start and it
var toApply = new List<string>();
// TakeWhile won't work because it doesn't include the actual target :(
foreach (var migration in migrator.GetPendingMigrations())
{
toApply.Add(migration);
if (IsMigration(migration, TargetMigration))
{
break;
}
}
if (!toApply.Any(s => IsMigration(s, TargetMigration)))
{
Log.Error("{0} is not a pending migration. Only the UP direction can be run in this way. Use the -Sql option to script downwards migrations.", TargetMigration);
return;
}
// We have a list of migrations to apply, apply them one-by-one
foreach (var migration in toApply)
{
Log.Info("Applying {0}", migration);
if (!WhatIf)
{
migrator.Update(migration);
}
}
Log.Info("All requested migrations applied");
}