本文整理汇总了C#中FluentMigrator.Runner.MigrationRunner.MigrateDown方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationRunner.MigrateDown方法的具体用法?C# MigrationRunner.MigrateDown怎么用?C# MigrationRunner.MigrateDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluentMigrator.Runner.MigrationRunner
的用法示例。
在下文中一共展示了MigrationRunner.MigrateDown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MigrateDown
public void MigrateDown(long targetVersion)
{
var announcer = new TextWriterAnnouncer(s => Debug.WriteLine(s));
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer);
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
using (var processor = factory.Create(connectionString, announcer, options))
{
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateDown(targetVersion, true);
}
}
示例2: MigrateDown
public static void MigrateDown(string connectionString)
{
var announcer = new NullAnnouncer();
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Hinata.Data.Migrations"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateDown(-1);
}
示例3: MigrateDownOne
public static void MigrateDownOne(string connectionString)
{
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Parakeet.Data.Migrator"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
using (var processor = factory.Create(connectionString, announcer, options))
{
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.VersionLoader.LoadVersionInfo();
runner.ListMigrations();
runner.MigrateDown(runner.VersionLoader.VersionInfo.Latest() - 1);
}
}
示例4: Migrate
public void Migrate(Action<IMigrationRunner> runnerAction)
{
var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 };
var factory = new FluentMigrator.Runner.Processors.SQLite.SQLiteProcessorFactory();
var assembly = Assembly.GetExecutingAssembly();
//using (var announcer = new NullAnnouncer())
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var migrationContext = new RunnerContext(announcer)
{
#if DEBUG
// will create testdata
Profile = "development"
#endif
};
using (var processor = factory.Create(connectionString, announcer, options))
{
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateDown(0);
runner.MigrateUp(true);
}
}
示例5: Migrate
/// <summary>
/// Runs database migrations of the specified module descriptor.
/// </summary>
/// <param name="moduleDescriptor">The module descriptor.</param>
/// <param name="up">if set to <c>true</c> migrates up; otherwise migrates down.</param>
public void Migrate(ModuleDescriptor moduleDescriptor, bool up = true)
{
var announcer = new TextWriterAnnouncer(
s =>
{
if (!string.IsNullOrWhiteSpace(s))
{
Log.Info(string.Concat("Migration on ", moduleDescriptor.Name, ". ", s));
}
});
var assembly = moduleDescriptor.GetType().Assembly;
var migrationTypes = assemblyLoader.GetLoadableTypes(assembly, typeof(Migration));
if (!migrationTypes.Any())
{
Log.Info(string.Concat("Migration on ", moduleDescriptor.Name, ". No migrations found."));
return;
}
var migrationContext = new RunnerContext(announcer)
{
Namespace = migrationTypes.First().Namespace
};
IMigrationProcessorOptions options = new ProcessorOptions
{
PreviewOnly = false,
Timeout = (int)migrationTimeout.TotalSeconds
};
IMigrationProcessor processor;
var connectionString = ConfigurationManager.ConnectionStrings["BetterCms"].ConnectionString;
if (databaseType == DatabaseType.SqlAzure || databaseType == DatabaseType.SqlServer)
{
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
processor = factory.Create(connectionString, announcer, options);
}
else if (databaseType == DatabaseType.PostgreSQL)
{
var factory = new FluentMigrator.Runner.Processors.Postgres.PostgresProcessorFactory();
processor = factory.Create(connectionString, announcer, options);
}
else if (databaseType == DatabaseType.Oracle)
{
var factory = new FluentMigrator.Runner.Processors.Oracle.OracleProcessorFactory();
processor = factory.Create(connectionString, announcer, options);
}
else
{
throw new NotSupportedException(string.Format("Database type {0} is not supported for data migrations.", databaseType));
}
var runner = new MigrationRunner(assembly, migrationContext, processor);
if (up)
{
runner.MigrateUp();
}
else
{
runner.MigrateDown(0);
}
}
示例6: CanAutoReverseAVersionDown
public void CanAutoReverseAVersionDown()
{
ExecuteWithSupportedProcessors(processor =>
{
Assembly asm = typeof(MigrationRunnerTests).Assembly;
var runnerContext = new RunnerContext(new TextWriterAnnouncer(System.Console.Out));
runnerContext.Namespace = "FluentMigrator.Tests.Integration.Migrations";
runnerContext.AutoReverse = true;
var runner = new MigrationRunner(asm, runnerContext, processor);
runner.MigrateUp(1);
runner.VersionLoader.VersionInfo.HasAppliedMigration(1).ShouldBeTrue();
processor.TableExists("Users").ShouldBeTrue();
runner.MigrateDown(1);
runner.VersionLoader.VersionInfo.HasAppliedMigration(1).ShouldBeFalse();
processor.TableExists("Users").ShouldBeFalse();
});
}