Пример #1
0
        public static void Upgrade([Required, Description(MigratorsHelp)] MigratorConfig[] migrators,
                                   [Required, Description(ConnectionStrNameHelp)] string connectionStringName,
                                   [Required, Description(StartUpConfigFileHelp)] string startUpConfigurationFile,
                                   [Description(StartUpDataDirHelp)] string startUpDataDirectory,
                                   [Description(SkippedMigrationsHelp)] string[] skippedMigrations)
        {
            // todo: remove requirement that connectionStringName and therefore startUpConfigurationFile is required
            // by allowing connectionString and providerName to be supplied as an alternative
            using (DbConnection cnn = CreateDbConnection(startUpConfigurationFile, connectionStringName))
            {
                List <DelegatedMigrator> ms =
                    migrators.Select(
                        c =>
                        CreateMigrator(startUpConfigurationFile, startUpDataDirectory, connectionStringName, c, cnn)
                        ).ToList();

                using (var migrationRunner = new MultiMigrateDbToLastestVsRunner(ms)
                {
                    SkippedMigrations = skippedMigrations
                })
                {
                    migrationRunner.Run();
                }
            }
        }
Пример #2
0
        public void CanMigrateDbFromMultipleConfigurations()
        {
            var bdf = CreateToolingFacadeForBaseData();
            var bdm = new DelegatedMigrator(bdf.GetPendingMigrations, bdf.GetDatabaseMigrations, migration => bdf.Update(migration, true), (s, t) => bdf.ScriptUpdate(s, t, true), CreateDbConnection());
            var mdf = CreateToolingFacadeForMainData();
            var mdm = new DelegatedMigrator(mdf.GetPendingMigrations, mdf.GetDatabaseMigrations, migration => mdf.Update(migration, true), (s, t) => mdf.ScriptUpdate(s, t, true), CreateDbConnection())
            {
                IsAutoMigrationsEnabled = true
            };
            var migrationRunner = new MultiMigrateDbToLastestVsRunner(new[] { bdm, mdm })
            {
                SkippedMigrations = new[] { "201501032326177_Rename LookupItem pk" }
            };

            migrationRunner.Run();
        }