Beispiel #1
0
        public MigrateTask(Func <Vertica.Integration.Infrastructure.Database.IDbFactory> db, ILogger logger, IKernel kernel, IMigrationDbs dbs, ITaskFactory taskFactory, ITaskRunner taskRunner)
        {
            StringBuilder stringBuilder;

            this._kernel      = kernel;
            this._taskFactory = taskFactory;
            this._taskRunner  = taskRunner;
            if (!dbs.IntegrationDbDisabled)
            {
                string str = MigrateTask.EnsureIntegrationDb(db(), dbs.CheckExistsAndCreateIntegrationDbIfNotFound, out this._databaseCreated);
                IntegrationMigrationDb integrationMigrationDb = new IntegrationMigrationDb(dbs.IntegrationDbDatabaseServer, ConnectionString.FromText(str), typeof(M1_Baseline).Assembly, typeof(M1_Baseline).Namespace);
                if (!this.CreateRunner(integrationMigrationDb, out stringBuilder).VersionLoader.VersionInfo.HasAppliedMigration(MigrateTask.FindLatestMigration()))
                {
                    this._loggingDisabler = logger.Disable();
                }
                dbs = dbs.WithIntegrationDb(integrationMigrationDb);
            }
            this._dbs = dbs.ToArray <MigrationDb>();
        }
Beispiel #2
0
        private MigrationRunner CreateRunner(MigrationDb db, out StringBuilder output)
        {
            StringBuilder stringBuilder  = new StringBuilder();
            StringBuilder stringBuilder1 = stringBuilder;

            output = stringBuilder;
            StringBuilder       stringBuilder2      = stringBuilder1;
            TextWriterAnnouncer textWriterAnnouncer = new TextWriterAnnouncer((string s) => {
                if (stringBuilder2.Length == 0)
                {
                    stringBuilder2.AppendLine();
                }
                stringBuilder2.Append(s);
            });
            IMigrationProcessor migrationProcessor = MigrateTask.CreateFactory(db.DatabaseServer).Create(db.ConnectionString, textWriterAnnouncer, new MigrateTask.MigrationOptions());
            RunnerContext       runnerContext      = new RunnerContext(textWriterAnnouncer)
            {
                Namespace          = db.NamespaceContainingMigrations,
                ApplicationContext = this._kernel
            };

            return(new MigrationRunner(db.Assembly, runnerContext, migrationProcessor));
        }