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); }
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); }
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); }