コード例 #1
0
        public PostgreSQLEventStoreMigration(
            ILogger <PostgreSQLEventStoreMigration> logger,
            DbUpMigration.Factory factory,
            IClaptrapIdentity identity,
            IDbFactory dbFactory,
            IStorageMigrationContainer storageMigrationContainer,
            IPostgreSQLEventStoreOptions options)
        {
            var(connectionName, schemaName, eventTableName) =
                options.RelationalEventStoreLocator.GetNames(identity);
            var migrationOptions = new DbUpMigrationOptions(
                new[] { Assembly.GetExecutingAssembly() },
                fileName => fileName.EndsWith("-event.sql"),
                new Dictionary <string, string>
            {
                { "SchemaName", schemaName },
                { "EventTableName", eventTableName }
            },
                () =>
                (DeployChanges
                 .To.PostgresqlDatabase(dbFactory.GetConnectionString(connectionName)), null));

            var migration    = factory.Invoke(logger, migrationOptions);
            var migrationKey =
                $"{nameof(PostgreSQLEventStoreMigration)}_{connectionName}_{schemaName}_{eventTableName}";

            _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration);
        }
コード例 #2
0
        public SQLiteEventStoreMigration(
            ILogger <SQLiteEventStoreMigration> logger,
            DbUpMigration.Factory factory,
            ISQLiteDbFactory sqLiteDbFactory,
            IStorageMigrationContainer storageMigrationContainer,
            IMasterOrSelfIdentity masterOrSelfIdentity,
            ISQLiteEventStoreOptions options)
        {
            var identity         = masterOrSelfIdentity.Identity;
            var storeLocator     = options.RelationalEventStoreLocator;
            var connectionName   = storeLocator.GetConnectionName(identity);
            var eventTableName   = storeLocator.GetEventTableName(identity);
            var migrationOptions = new DbUpMigrationOptions(
                new[] { Assembly.GetExecutingAssembly() },
                fileName => fileName.EndsWith("-event.sql"),
                new Dictionary <string, string>
            {
                { "EventTableName", eventTableName }
            },
                () =>
            {
                var dbConnection = sqLiteDbFactory.GetConnection(connectionName);
                var builder      = DeployChanges.To.SQLiteDatabase(new SharedConnection(dbConnection));
                return(builder, dbConnection);
            });
            var migration    = factory.Invoke(logger, migrationOptions);
            var migrationKey =
                $"{nameof(SQLiteEventStoreMigration)}_{connectionName}_{eventTableName}";

            _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration);
        }
コード例 #3
0
        public MySqlStateStoreMigration(
            ILogger <MySqlStateStoreMigration> logger,
            DbUpMigration.Factory factory,
            IClaptrapIdentity identity,
            IDbFactory dbFactory,
            IStorageMigrationContainer storageMigrationContainer,
            IRelationalStateStoreLocatorOptions options)
        {
            var locator          = options.RelationalStateStoreLocator;
            var connectionName   = locator.GetConnectionName(identity);
            var schemaName       = locator.GetSchemaName(identity);
            var stateTableName   = locator.GetStateTableName(identity);
            var migrationOptions = new DbUpMigrationOptions(
                new[] { Assembly.GetExecutingAssembly() },
                fileName => fileName.EndsWith("-state.sql"),
                new Dictionary <string, string>
            {
                { "SchemaName", schemaName },
                { "StateTableName", stateTableName },
            },
                () =>
                (DeployChanges
                 .To.MySqlDatabase(dbFactory.GetConnectionString(connectionName)), null));

            var migration    = factory.Invoke(logger, migrationOptions);
            var migrationKey =
                $"{nameof(MySqlStateStoreMigration)}_{connectionName}_{schemaName}_{stateTableName}";

            _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration);
        }
コード例 #4
0
        public MongoDBStateStoreMigration(
            IClaptrapIdentity identity,
            IDbFactory dbFactory,
            IStorageMigrationContainer storageMigrationContainer,
            IMongoDBStateStoreLocatorOptions options)
        {
            var locator             = options.MongoDBStateStoreLocator;
            var connectionName      = locator.GetConnectionName(identity);
            var databaseName        = locator.GetDatabaseName(identity);
            var stateCollectionName = locator.GetStateCollectionName(identity);
            var migration           = new InternalMongoDBSharedCollectionEventStoreMigration(
                connectionName,
                databaseName,
                stateCollectionName,
                dbFactory);
            var migrationKey =
                $"{nameof(MongoDBEventStoreMigration)}_{stateCollectionName}_{databaseName}_{connectionName}";

            _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration);
        }
コード例 #5
0
        public MongoDBEventStoreMigration(
            ILogger <MongoDBEventStoreMigration> logger,
            IDbFactory dbFactory,
            IMasterOrSelfIdentity masterOrSelfIdentity,
            IStorageMigrationContainer storageMigrationContainer,
            IMongoDBEventStoreOptions options)
        {
            var locator             = options.MongoDBEventStoreLocator;
            var identity            = masterOrSelfIdentity.Identity;
            var connectionName      = locator.GetConnectionName(identity);
            var databaseName        = locator.GetDatabaseName(identity);
            var eventCollectionName = locator.GetEventCollectionName(identity);
            var migration           = new InternalMongoDBSharedCollectionEventStoreMigration(
                connectionName,
                databaseName,
                eventCollectionName,
                dbFactory);
            var migrationKey =
                $"{nameof(MongoDBEventStoreMigration)}_{connectionName}_{databaseName}_{eventCollectionName}";

            _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration);
        }