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


C# Migrator.Migrate方法代码示例

本文整理汇总了C#中Migrator.Migrate方法的典型用法代码示例。如果您正苦于以下问题:C# Migrator.Migrate方法的具体用法?C# Migrator.Migrate怎么用?C# Migrator.Migrate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Migrator的用法示例。


在下文中一共展示了Migrator.Migrate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDatabase

 public static void CreateDatabase(string dbName, string relativePath)
 {
     string dbFilePath = GetAbsoluteDatabaseFilePath(dbName, relativePath);
     string connectionString = ConnectionString(dbFilePath);
     Migrator migrator = new Migrator(connectionString);
     #if DEBUG
     migrator.Migrate(runner => runner.MigrateDown(0));
     #endif
     migrator.Migrate(runner => runner.MigrateUp());
     DapperExtensions.DapperExtensions.DefaultMapper = typeof(PluralizedAutoClassMapper<>);
 }
开发者ID:4201715125,项目名称:S4201715125V1,代码行数:11,代码来源:RepositoryBase.cs

示例2: Execute

        public override bool Execute()
        {
            using (var store = new DocumentStore())
            {
                store.ConfigureUsingConnectionString(ConnectionString);
                store.Initialize();

                var migrator = new Migrator();
                foreach (var item in Migrations)
                {
                    var assembly = Assembly.LoadFrom(item.GetMetadata("FullPath"));
                    migrator.Migrate(store, assembly, ToVersion);
                }
            }

            if (ToVersion > 0)
            {
                Log.LogMessage("Migrated to version " + ToVersion + ".");
            }
            else
            {
                Log.LogMessage("Migrated to maximum version.");
            }
            return true;
        }
开发者ID:andrewdavey,项目名称:ravendb-migrations,代码行数:25,代码来源:Migrate.cs

示例3: Can_Export_Database_Into_Export_File

        public void Can_Export_Database_Into_Export_File()
        {
            var migrator = new Migrator();
            migrator.Migrate();

            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BlogMLExportWorker.ExportFileName);
            var exportFile = new FileInfo(path);

            Assert.True(exportFile.Exists);
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:10,代码来源:MigratorFacts.cs

示例4: create_database_and_apply_all_migrations

        public void create_database_and_apply_all_migrations()
        {
            Mock<ISupplyMigrations> source = SetupSource();

            Mock<ICommandDatabases> handler = SetupHandler(new DatabaseVersion {Type = DatabaseVersionType.NotCreated});
            Mock<ICompareMigrations> comparer = SetupComparer();
            var migrator = new Migrator(source.Object, comparer.Object, handler.Object);
            migrator.Migrate();
            handler.Verify(h => h.Create(), Times.Once);
            handler.Verify(h => h.CreateMigrationHistoryTable(), Times.Never);
            handler.Verify(h => h.ExecuteMigration(It.IsAny<Migration>()), Times.Exactly(2));
        }
开发者ID:pperboires,项目名称:SqlMigrator,代码行数:12,代码来源:MigratorFacts.cs

示例5: Can_Deserialize_Exported_File

        public void Can_Deserialize_Exported_File()
        {
            var migrator = new Migrator();
            migrator.Migrate();

            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BlogMLExportWorker.ExportFileName);
            var file = new FileStream(path, FileMode.Open);
            var blog = BlogMLSerializer.Deserialize(file);

            Assert.NotNull(blog);
            Assert.NotEqual(0, blog.Posts.Count);
            Assert.NotEqual(0, blog.Categories.Count);
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:13,代码来源:MigratorFacts.cs

示例6: Initialise

        public void Initialise(IConfigSource configSource)
        {
            IConfig config = configSource.Configs["EventRecorder"];
            m_connectionString = config.GetString("ConnectionString");

            if (m_connectionString == null)
                throw new Exception("No ConnectionString parameter found in [EventRecorder] config for MySQLRecorder");

            //            m_log.DebugFormat("[MYSQL EVENT RECORDER]: Got connection string '{0}'", m_connectionString);

            Migrator migrator = new Migrator(m_connectionString);
            migrator.Migrate(runner => runner.MigrateUp());
        }
开发者ID:justinccdev,项目名称:EventRecordingModule,代码行数:13,代码来源:MySQLRecorder.cs

示例7: apply_no_migrations

        public void apply_no_migrations()
        {
            Mock<ISupplyMigrations> source = SetupSource();

            Mock<ICommandDatabases> handler =
                SetupHandler(new DatabaseVersion {Type = DatabaseVersionType.VersionNumber, Number = "1"});
            Mock<ICompareMigrations> comparer = SetupComparer();
            var migrator = new Migrator(source.Object, comparer.Object, handler.Object);
            migrator.Migrate();
            handler.Verify(h => h.Create(), Times.Never);
            handler.Verify(h => h.CreateMigrationHistoryTable(), Times.Never);
            handler.Verify(h => h.ExecuteMigration(It.IsAny<Migration>()), Times.Never);
        }
开发者ID:pperboires,项目名称:SqlMigrator,代码行数:13,代码来源:MigratorFacts.cs

示例8: Exports_Post_Category_Relations

        public void Exports_Post_Category_Relations()
        {
            var migrator = new Migrator();
            migrator.Migrate();

            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BlogMLExportWorker.ExportFileName);
            var file = new FileStream(path, FileMode.Open);
            var blog = BlogMLSerializer.Deserialize(file);

            var post = blog.Posts[0];
            var categories = post.Categories;

            Assert.NotNull(categories);
            Assert.NotEmpty(categories);
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:15,代码来源:MigratorFacts.cs

示例9: MigrateSettings

		public static void MigrateSettings(bool createTargetCategoryAndFields,
		                                   bool migrateFieldValues,
		                                   IMemento newState,
		                                   IMemento oldState)
		{
			Migrator migrator = new Migrator();

			if (createTargetCategoryAndFields)
			{
				migrator.EnsureTargetCategory(newState.CategoryName);
				migrator.EnsureFields(newState.CategoryName, new MigrationInfo(oldState, newState).AllFields);
			}

			if (migrateFieldValues)
			{
				migrator.Migrate(new MigrationInfo(oldState, newState));
			}
		}
开发者ID:agross,项目名称:graffiti-usergroups,代码行数:18,代码来源:PluginMigrator.cs

示例10: DoManatee

        private static void DoManatee(InputParameters settings)
        {
            // Export
            if(settings.Command == Command.Export)
            {
                Logger.WriteLine(ConsoleColor.Green, "Exporting migrations from connection {0}", settings.Connection);

                var deriver = new MigrationExporter(settings.MigrationFolder, settings.Connection, settings.Table);
                deriver.DoExport();
                return;
            }

            // Generate
            if (settings.Command == Command.Gen)
            {
                Logger.WriteLine(ConsoleColor.Green, "Generating new migration file");

                var fileName = string.Format("{0}_{1}.json", DateTime.Now.ToString("yyyyMMdd_HHmm"), settings.Name);
                var content = @"{
            up: {

            },
            down: {
            }
            }";
                var outputPath = Path.Combine(settings.MigrationFolder, fileName);
                File.WriteAllText(outputPath, content, Encoding.UTF8);

                Logger.WriteLine("Generated new file: {0}", fileName);
                return;
            }

            var migrator = new Migrator(settings.MigrationFolder, settings.Connection);

            // List
            if(settings.Command == Command.List)
            {
                Logger.WriteLine(ConsoleColor.Green, "Listing migrations from Folder {0} and connection {1}", settings.MigrationFolder, settings.Connection);
                Logger.WriteLine("    Current Version: {0}", migrator.CurrentVersion);
                int counter = 0;
                foreach(var migration in migrator.Migrations)
                {
                    counter++;
                    bool isCurrent = migrator.CurrentVersion == counter;
                    var msg = string.Format("    {0}: {1}{2}", counter, migration.Key, isCurrent ? " (current)" : string.Empty);
                    if (isCurrent)
                        Logger.WriteLine(ConsoleColor.Green, msg);
                    else
                        Logger.WriteLine("    {0}: {1}", counter, migration.Key);
                }
                return;
            }

            // Execute
            if(settings.Command == Command.Goto)
            {
                Logger.WriteLine(ConsoleColor.Green, "Executing migrations from Folder {0} and connection {1}", settings.MigrationFolder, settings.Connection);

                var destinationVersion = DetermineVersion(settings, migrator);
                destinationVersion = Math.Min(destinationVersion, migrator.Migrations.Count);
                Logger.WriteLine("    Current Version: {0}", migrator.CurrentVersion);
                Logger.WriteLine("    Going to Version: {0}", destinationVersion);

                migrator.Migrate(destinationVersion);
                Logger.WriteLine(ConsoleColor.Yellow, "Migrations successful");
            }
        }
开发者ID:thomasvm,项目名称:ManateeCommand,代码行数:67,代码来源:Program.cs

示例11: migration_must_be_done_in_a_lock

        public void migration_must_be_done_in_a_lock()
        {
            using (Sequence.Create())
            {
                Mock<ISupplyMigrations> source = SetupSource();

                Mock<ICommandDatabases> handler =
                    SetupHandler(new DatabaseVersion { Type = DatabaseVersionType.VersionNumber, Number = "-1" });
                Mock<ICompareMigrations> comparer = SetupComparer();

                Mock<ILocker> locker = SetupLocker();

                locker.Setup(x => x.Lock()).InSequence(Times.Exactly(1));
                handler.Setup(x => x.ExecuteMigration(It.IsAny<Migration>())).InSequence(Times.Exactly(2));
                locker.Setup(x => x.Release()).InSequence(Times.Exactly(1));

                var migrator = new Migrator(source.Object, comparer.Object, handler.Object, locker.Object);
                migrator.Migrate();
                handler.Verify(h => h.Create(), Times.Never);
                handler.Verify(h => h.CreateMigrationHistoryTable(), Times.Never);
            }
        }
开发者ID:pperboires,项目名称:SqlMigrator,代码行数:22,代码来源:MigratorFacts.cs

示例12: migrate_with_full_connection_string

 public void migrate_with_full_connection_string()
 {
     database = "db_" + Guid.NewGuid().ToString("N");
     var migrator = new Migrator(SetupSource().Object, new NumberComparer(),
         new SqlServerCommander(CreateDatabaseConnection));
     migrator.Migrate();
     using (IDbConnection connection = CreateConnection())
     {
         connection.Open();
         using (IDbCommand cmd = connection.CreateCommand())
         {
             cmd.CommandText = string.Format("select count(*) from sys.databases where name='{0}'", database);
             object result = cmd.ExecuteScalar();
             Assert.AreEqual(1, result);
         }
     }
 }
开发者ID:pperboires,项目名称:SqlMigrator,代码行数:17,代码来源:DatabaseFacts.cs


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