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


C# MigrationRunner.MigrateDown方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Test-Factory,项目名称:TestFactory,代码行数:14,代码来源:Migrator.cs

示例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);
        }
开发者ID:sunlight0915,项目名称:Hinata-on-premise,代码行数:16,代码来源:Database.cs

示例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);
            }
        }
开发者ID:NeverOddOrEven,项目名称:Parakeet,代码行数:20,代码来源:Runner.cs

示例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);
            }
        }
开发者ID:TicketArchitecture,项目名称:Api-Template,代码行数:23,代码来源:DebugMigrator.cs

示例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);
            }
        }
开发者ID:pmaciulis,项目名称:BetterCMS,代码行数:71,代码来源:DefaultMigrationRunner.cs

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


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