本文整理汇总了C#中Migrator.MigrateTo方法的典型用法代码示例。如果您正苦于以下问题:C# Migrator.MigrateTo方法的具体用法?C# Migrator.MigrateTo怎么用?C# Migrator.MigrateTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migrator
的用法示例。
在下文中一共展示了Migrator.MigrateTo方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_migrator = new Migrator(TransformationProvider, MigrationAssembly, true);
Assert.IsTrue(_migrator.MigrationsTypes.Count > 0, "No migrations in assembly " + MigrationAssembly.Location);
_migrator.MigrateTo(0);
}
示例2: SetUp
public void SetUp()
{
_migrator = new Migrator(TransformationProvider);
Assert.IsTrue(_migrator.MigrationsTypes.Count > 0);
_migrator.MigrateTo(0);
}
示例3: MigratorThrowsErrorIfDuplicateTimestampProvidersFoundForModule
public void MigratorThrowsErrorIfDuplicateTimestampProvidersFoundForModule()
{
var migrator = new Migrator("not-used", ProviderNames.SQLite, new MigrationOptions("TimestampProviderDuplicateTest"));
migrator.MigrateTo(_duplicateProviderTestAssembly, 1);
}
示例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);
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: TestScriptingAndExecutingMigration1
public void TestScriptingAndExecutingMigration1()
{
DirectoryInfo targetDirectory = PrepareScriptingDirectory();
_options.VersioningTableName = "My Versioning Table"; // test overriding the default versioning table name
_options.ExecuteAndScriptSqlTo(targetDirectory);
var migrator = new Migrator(ConnectionString, ProviderName, _options);
migrator.MigrateTo(typeof(Migration1).Assembly, Timestamps[0]);
CheckResultsOfMigration1();
// assert that the script file was generated
FileInfo[] scriptFiles = targetDirectory.GetFiles(string.Format(CultureInfo.InvariantCulture, "Migration." + MigrationExportAttribute.DefaultModuleName + ".1.sql"));
Assert.AreEqual(1, scriptFiles.Length);
// delete script files
targetDirectory.Delete(true);
}
示例6: TestMigration1SucceededByAllOtherMigrations
public void TestMigration1SucceededByAllOtherMigrations()
{
// execute Migration1
var migrator = new Migrator(ConnectionString, ProviderName, _options);
Assembly assemblyContainingMigrations = typeof(Migration1).Assembly;
migrator.MigrateTo(assemblyContainingMigrations, Timestamps[0]);
// execute all other migrations
migrator = new Migrator(ConnectionString, ProviderName, _options);
migrator.MigrateAll(assemblyContainingMigrations);
Assert.IsTrue(migrator.IsUpToDate(assemblyContainingMigrations));
VerifyResultsOfAllMigrations();
}
示例7: TestMigration1
public void TestMigration1()
{
_options.VersioningTableName = "My Versioning Table"; // test overriding the default versioning table name
var migrator = new Migrator(ConnectionString, ProviderName, _options);
migrator.MigrateTo(typeof(Migration1).Assembly, Timestamps[0]);
CheckResultsOfMigration1();
}
示例8: RunMigration
void RunMigration(Migrator mig)
{
if (mig.DryRun)
mig.Logger.Log("********** Dry run! Not actually applying changes. **********");
if (_to == -1)
mig.MigrateToLastVersion();
else
mig.MigrateTo(_to);
}
示例9: 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.");
}
示例10: TestMigration1SucceededByAllOtherMigrations
public void TestMigration1SucceededByAllOtherMigrations()
{
// execute Migration1
var migrator = new Migrator(ConnectionString, ProviderName, _options);
Assembly assemblyContainingMigrations = typeof(Migration1).Assembly;
migrator.MigrateTo(assemblyContainingMigrations, Timestamps[0]);
// execute all other migrations
migrator = new Migrator(ConnectionString, ProviderName, _options);
migrator.MigrateAll(assemblyContainingMigrations);
// make sure there are no more migrations to run
IMigrationBatch batch = migrator.FetchMigrations(assemblyContainingMigrations);
Assert.AreEqual(0, batch.ScheduledMigrations.Count);
VerifyResultsOfAllMigrations();
}
示例11: 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();
}
示例12: MigrateDown
public void MigrateDown()
{
var migrator = new Migrator(_config.ConnectionString, ProviderNames.SqlServer2008, _options);
migrator.MigrateTo(typeof(V001_Initial_1).Assembly, 0);
}
示例13: RunMigration
public void RunMigration(Migrator.Migrator mig)
{
if (mig.DryRun)
{
mig.Logger.Log("********** Dry run! Not actually applying changes. **********", new object[0]);
}
if (this.To == -1L)
{
mig.MigrateToLastVersion();
}
else
{
mig.MigrateTo(this.To);
}
}
示例14: MigratorUsesModuleSpecificTimestampProvider
public void MigratorUsesModuleSpecificTimestampProvider()
{
var errorThrown = false;
var migrator = new Migrator("not-used", ProviderNames.SQLite, new MigrationOptions("TimestampProviderTest"));
try
{
migrator.MigrateTo(_timestampModuleTestAssembly, 1);
}
catch (NotImplementedException ex)
{
Assert.AreEqual("TimestampProviderTest called", ex.Message);
errorThrown = true;
}
Assert.IsTrue(errorThrown, "Timestamp Provider not called");
}