当前位置: 首页>>代码示例>>C#>>正文


C# Migrator.FetchMigrationsTo方法代码示例

本文整理汇总了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
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:9,代码来源:MigratorTests.cs

示例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);
        }
开发者ID:halad,项目名称:MigSharp,代码行数:26,代码来源:IntegrationTestsBase.cs

示例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();
        }
开发者ID:halad,项目名称:MigSharp,代码行数:18,代码来源:IntegrationTestsBase.cs

示例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.");
        }
开发者ID:halad,项目名称:MigSharp,代码行数:30,代码来源:IntegrationTestsBase.cs

示例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();
 }
开发者ID:dradovic,项目名称:MigSharp,代码行数:6,代码来源:Program.cs


注:本文中的Migrator.FetchMigrationsTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。