public DatabaseUpgradeComponent(IMigrationPlanExecutor migrationPlanExecutor, IScopeProvider scopeProvider, IKeyValueService keyValueService, IRuntimeState runtimeState)
 {
     _migrationPlanExecutor = migrationPlanExecutor;
     _scopeProvider         = scopeProvider;
     _keyValueService       = keyValueService;
     _runtimeState          = runtimeState;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseBuilder"/> class.
 /// </summary>
 public DatabaseBuilder(
     IScopeProvider scopeProvider,
     IScopeAccessor scopeAccessor,
     IUmbracoDatabaseFactory databaseFactory,
     IRuntimeState runtimeState,
     ILoggerFactory loggerFactory,
     IKeyValueService keyValueService,
     IDbProviderFactoryCreator dbProviderFactoryCreator,
     IConfigManipulator configManipulator,
     IOptionsMonitor <GlobalSettings> globalSettings,
     IOptionsMonitor <ConnectionStrings> connectionStrings,
     IMigrationPlanExecutor migrationPlanExecutor,
     DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory,
     IEnumerable <IDatabaseProviderMetadata> databaseProviderMetadata)
 {
     _scopeProvider                = scopeProvider;
     _scopeAccessor                = scopeAccessor;
     _databaseFactory              = databaseFactory;
     _runtimeState                 = runtimeState;
     _logger                       = loggerFactory.CreateLogger <DatabaseBuilder>();
     _keyValueService              = keyValueService;
     _dbProviderFactoryCreator     = dbProviderFactoryCreator;
     _configManipulator            = configManipulator;
     _globalSettings               = globalSettings;
     _connectionStrings            = connectionStrings;
     _migrationPlanExecutor        = migrationPlanExecutor;
     _databaseSchemaCreatorFactory = databaseSchemaCreatorFactory;
     _databaseProviderMetadata     = databaseProviderMetadata;
 }
        public void MigrationCanAddPostMigration()
        {
            IMigrationBuilder builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                switch (t.Name)
                {
                case nameof(NoopMigration):
                    return(new NoopMigration(c));

                case nameof(TestMigration):
                    return(new TestMigration(c));

                case nameof(TestPostMigration):
                    return(new TestPostMigration(c));

                default:
                    throw new NotSupportedException();
                }
            });

            var    database = new TestDatabase();
            IScope scope    = Mock.Of <IScope>(x => x.Notifications == Mock.Of <IScopedNotificationPublisher>());

            Mock.Get(scope)
            .Setup(x => x.Database)
            .Returns(database);

            var sqlContext = new SqlContext(
                new SqlServerSyntaxProvider(Options.Create(new GlobalSettings())),
                DatabaseType.SQLCe,
                Mock.Of <IPocoDataFactory>());
            var scopeProvider = new MigrationTests.TestScopeProvider(scope)
            {
                SqlContext = sqlContext
            };

            MigrationPlan plan = new MigrationPlan("Test")
                                 .From(string.Empty).To <TestMigration>("done");

            TestMigration.MigrateCount     = 0;
            TestPostMigration.MigrateCount = 0;

            new MigrationContext(plan, database, s_loggerFactory.CreateLogger <MigrationContext>());

            var upgrader = new Upgrader(plan);
            IMigrationPlanExecutor executor = GetMigrationPlanExecutor(scopeProvider, scopeProvider, builder);

            upgrader.Execute(
                executor,
                scopeProvider,
                Mock.Of <IKeyValueService>());

            Assert.AreEqual(1, TestMigration.MigrateCount);
            Assert.AreEqual(1, TestPostMigration.MigrateCount);
        }
Beispiel #4
0
 /// <inheritdoc/>
 public FirstBootAppStartingHandler(
     ICoreScopeProvider scopeProvider,
     IKeyValueService keyValueService,
     IMigrationPlanExecutor migrationPlanExecutor)
 {
     _scopeProvider         = scopeProvider;
     _keyValueService       = keyValueService;
     _migrationPlanExecutor = migrationPlanExecutor;
 }
Beispiel #5
0
 public UmbracoApplicationStartingHandler(IScopeProvider scopeProvider,
                                          IMigrationPlanExecutor migrationPlanExecutor,
                                          IKeyValueService keyValueService,
                                          IRuntimeState runtimeState)
 {
     _scopeProvider         = scopeProvider;
     _migrationPlanExecutor = migrationPlanExecutor;
     _keyValueService       = keyValueService;
     _runtimeState          = runtimeState;
 }
 public MigrationComponent(
     IScopeProvider scopeProvider,
     IMigrationBuilder migrationBuilder,
     IMigrationPlanExecutor migrationPlanExecutor,
     IKeyValueService keyValueService)
 {
     _scopeProvider         = scopeProvider;
     _migrationBuilder      = migrationBuilder;
     _migrationPlanExecutor = migrationPlanExecutor;
     _keyValueService       = keyValueService;
 }
Beispiel #7
0
 public IconicMigrations(
     IScopeProvider scopeProvider,
     IMigrationPlanExecutor migrationPlanExecutor,
     IKeyValueService keyValueService,
     IRuntimeState runtimeState)
 {
     _scopeProvider         = scopeProvider;
     _migrationPlanExecutor = migrationPlanExecutor;
     _keyValueService       = keyValueService;
     _runtimeState          = runtimeState;
 }
Beispiel #8
0
 public PackageMigrationRunner(
     IProfilingLogger profilingLogger,
     ICoreScopeProvider scopeProvider,
     PendingPackageMigrations pendingPackageMigrations,
     PackageMigrationPlanCollection packageMigrationPlans,
     IMigrationPlanExecutor migrationPlanExecutor,
     IKeyValueService keyValueService,
     IEventAggregator eventAggregator)
 {
     _profilingLogger          = profilingLogger;
     _scopeProvider            = scopeProvider;
     _pendingPackageMigrations = pendingPackageMigrations;
     _migrationPlanExecutor    = migrationPlanExecutor;
     _keyValueService          = keyValueService;
     _eventAggregator          = eventAggregator;
     _packageMigrationPlans    = packageMigrationPlans.ToDictionary(x => x.Name);
 }