本文整理汇总了C#中Migrator.FetchMigrationsTo方法的典型用法代码示例。如果您正苦于以下问题:C# Migrator.FetchMigrationsTo方法的具体用法?C# Migrator.FetchMigrationsTo怎么用?C# Migrator.FetchMigrationsTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migrator
的用法示例。
在下文中一共展示了Migrator.FetchMigrationsTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestIrreversibleMigrationExceptionIsThrown
public void TestIrreversibleMigrationExceptionIsThrown()
{
long timestamp2 = typeof(Migration2).GetTimestamp();
IVersioning versioning = GetVersioning(true, true, true);
Migrator migrator = new Migrator("", ProviderNames.SqlServer2008);
migrator.UseCustomVersioning(versioning);
migrator.FetchMigrationsTo(typeof(Migration1).Assembly, timestamp2); // should throw an IrreversibleMigrationException as Migration3 is irreversible
}
示例2: TestUnidentifiedMigrations
public void TestUnidentifiedMigrations()
{
if (ProviderName == ProviderNames.Teradata || ProviderName == ProviderNames.TeradataOdbc ||
ProviderName == ProviderNames.Oracle || ProviderName == ProviderNames.OracleOdbc) return; // for some reason, the ODBC data adapter updating does not work
// migrate to 1 in order to create a versioning table
var migrator = new Migrator(ConnectionString, ProviderName, _options);
IMigrationBatch batch = migrator.FetchMigrationsTo(typeof(Migration1).Assembly, Timestamps[0]);
Assert.AreEqual(0, batch.UnidentifiedMigrations.Count);
batch.Execute();
// insert unidentified migrations into the versioning table
DataTable versioningTable = GetTable(_options.VersioningTableName);
const long timestamp = 123456L;
const string moduleName = "Test";
const string tag = "This migration is not known to the application.";
versioningTable.Rows.Add(timestamp, moduleName, tag);
SaveTable(versioningTable);
// verify if the UnidentifiedMigrations is populated correctly
batch = migrator.FetchMigrations(typeof(Migration1).Assembly);
Assert.AreEqual(1, batch.UnidentifiedMigrations.Count);
Assert.AreEqual(timestamp, batch.UnidentifiedMigrations[0].Timestamp);
Assert.AreEqual(moduleName, batch.UnidentifiedMigrations[0].ModuleName);
Assert.AreEqual(tag, batch.UnidentifiedMigrations[0].Tag);
}
示例3: TestMigration1
public void TestMigration1()
{
_options.VersioningTableName = "My Versioning Table"; // test overriding the default versioning table name
var migrator = new Migrator(ConnectionString, ProviderName, _options);
// verify if the migrations batch is populated correctly
IMigrationBatch batch = migrator.FetchMigrationsTo(typeof(Migration1).Assembly, Timestamps[0]);
Assert.AreEqual(1, batch.ScheduledMigrations.Count);
Assert.AreEqual(Timestamps[0], batch.ScheduledMigrations[0].Timestamp);
Assert.AreEqual(MigrationExportAttribute.DefaultModuleName, batch.ScheduledMigrations[0].ModuleName);
Assert.IsNull(batch.ScheduledMigrations[0].Tag);
Assert.AreEqual(MigrationDirection.Up, batch.ScheduledMigrations[0].Direction);
// use MigrateTo to execute the actual migrations to test that method, too
migrator.MigrateTo(typeof(Migration1).Assembly, Timestamps[0]);
CheckResultsOfMigration1();
}
示例4: TestUndoingMigration2
public void TestUndoingMigration2()
{
var migrator = new Migrator(ConnectionString, ProviderName, _options);
Assembly assemblyContainingMigrations = typeof(Migration1).Assembly;
migrator.MigrateTo(assemblyContainingMigrations, Timestamps[1]);
migrator = new Migrator(ConnectionString, ProviderName);
// verify if the migrations batch is populated correctly
IMigrationBatch batch = migrator.FetchMigrationsTo(assemblyContainingMigrations, Timestamps[0]);
Assert.AreEqual(1, batch.ScheduledMigrations.Count, "Only the reversal of Migration2 should be scheduled.");
Assert.AreEqual(Timestamps[1], batch.ScheduledMigrations[0].Timestamp);
Assert.AreEqual(Migration2.Module, batch.ScheduledMigrations[0].ModuleName);
Assert.AreEqual(Migration2.Tag, batch.ScheduledMigrations[0].Tag);
Assert.AreEqual(MigrationDirection.Down, batch.ScheduledMigrations[0].Direction);
// use MigrateTo to execute the actual migrations to test that method, too
migrator.MigrateTo(assemblyContainingMigrations, Timestamps[0]);
// assert order table was dropped
DataTable orderTable = GetTable(new Migration2().Tables[0].Name);
Assert.IsNull(orderTable, "The order table was not dropped.");
// assert Versioning table has only necessary entries
DataTable versioningTable = GetTable(_options.VersioningTableName);
Assert.AreEqual(1, versioningTable.Rows.Count, "The versioning table is missing entries or has too much entries.");
Assert.AreEqual(Timestamps[0], versioningTable.Rows[0][0], "The timestamp of Migration1 is wrong.");
Assert.AreEqual(MigrationExportAttribute.DefaultModuleName, versioningTable.Rows[0][1], "The module of Migration1 is wrong.");
Assert.AreEqual(DBNull.Value, versioningTable.Rows[0][2], "The tag of Migration1 is wrong.");
}
示例5: ExecuteMigration
private static void ExecuteMigration(string connectionString, DbPlatform dbPlatform, MigrationOptions options, string assemblyPath, long timestamp, string[] additionalAssemblyPaths)
{
var migrator = new Migrator(connectionString, dbPlatform, options);
IMigrationBatch batch = migrator.FetchMigrationsTo(assemblyPath, timestamp, additionalAssemblyPaths);
batch.Execute();
}