public Migrator( [NotNull] MigrationAssembly migrationAssembly, [NotNull] IHistoryRepository historyRepository, [NotNull] IDataStoreCreator dataStoreCreator, [NotNull] IMigrationSqlGenerator migrationSqlGenerator, [NotNull] SqlStatementExecutor executor, [NotNull] IRelationalConnection connection, [NotNull] IModelDiffer modelDiffer, [NotNull] IModel model, [NotNull] MigrationIdGenerator idGenerator, [NotNull] ISqlGenerator sqlGenerator) { Check.NotNull(migrationAssembly, nameof(migrationAssembly)); Check.NotNull(historyRepository, nameof(historyRepository)); Check.NotNull(dataStoreCreator, nameof(dataStoreCreator)); Check.NotNull(migrationSqlGenerator, nameof(migrationSqlGenerator)); Check.NotNull(executor, nameof(executor)); Check.NotNull(connection, nameof(connection)); Check.NotNull(modelDiffer, nameof(modelDiffer)); Check.NotNull(model, nameof(model)); Check.NotNull(idGenerator, nameof(idGenerator)); Check.NotNull(sqlGenerator, nameof(sqlGenerator)); _migrationAssembly = migrationAssembly; _historyRepository = historyRepository; _dataStoreCreator = (IRelationalDataStoreCreator)dataStoreCreator; _migrationSqlGenerator = migrationSqlGenerator; _executor = executor; _connection = connection; _modelDiffer = modelDiffer; _model = model; _idGenerator = idGenerator; _sqlGenerator = sqlGenerator; }
public Migrator( [NotNull] DbContextConfiguration contextConfiguration, [NotNull] HistoryRepository historyRepository, [NotNull] MigrationAssembly migrationAssembly, [NotNull] ModelDiffer modelDiffer, [NotNull] IMigrationOperationSqlGeneratorFactory ddlSqlGeneratorFactory, [NotNull] SqlGenerator dmlSqlGenerator, [NotNull] SqlStatementExecutor sqlExecutor) { Check.NotNull(contextConfiguration, "contextConfiguration"); Check.NotNull(historyRepository, "historyRepository"); Check.NotNull(migrationAssembly, "migrationAssembly"); Check.NotNull(modelDiffer, "modelDiffer"); Check.NotNull(ddlSqlGeneratorFactory, "ddlSqlGeneratorFactory"); Check.NotNull(dmlSqlGenerator, "dmlSqlGenerator"); Check.NotNull(sqlExecutor, "sqlExecutor"); _contextConfiguration = contextConfiguration; _historyRepository = historyRepository; _migrationAssembly = migrationAssembly; _modelDiffer = modelDiffer; _ddlSqlGeneratorFactory = ddlSqlGeneratorFactory; _dmlSqlGenerator = dmlSqlGenerator; _sqlExecutor = sqlExecutor; }
public Migrator( [NotNull] HistoryRepository historyRepository, [NotNull] MigrationAssembly migrationAssembly, [NotNull] ModelDiffer modelDiffer, [NotNull] IMigrationOperationSqlGeneratorFactory ddlSqlGeneratorFactory, [NotNull] SqlGenerator dmlSqlGenerator, [NotNull] SqlStatementExecutor sqlExecutor, [NotNull] RelationalDataStoreCreator storeCreator, [NotNull] RelationalConnection connection, [NotNull] ILoggerFactory loggerFactory) { Check.NotNull(historyRepository, "historyRepository"); Check.NotNull(migrationAssembly, "migrationAssembly"); Check.NotNull(modelDiffer, "modelDiffer"); Check.NotNull(ddlSqlGeneratorFactory, "ddlSqlGeneratorFactory"); Check.NotNull(dmlSqlGenerator, "dmlSqlGenerator"); Check.NotNull(sqlExecutor, "sqlExecutor"); Check.NotNull(storeCreator, "storeCreator"); Check.NotNull(connection, "connection"); Check.NotNull(loggerFactory, "loggerFactory"); _historyRepository = historyRepository; _migrationAssembly = migrationAssembly; _modelDiffer = modelDiffer; _ddlSqlGeneratorFactory = ddlSqlGeneratorFactory; _dmlSqlGenerator = dmlSqlGenerator; _sqlExecutor = sqlExecutor; _storeCreator = storeCreator; _connection = connection; _logger = new DbContextService <ILogger>(loggerFactory.Create <Migrator>); }
protected override bool HasTables() { var count = (long)SqlStatementExecutor.ExecuteScalar( Connection, "SELECT COUNT(*) FROM \"sqlite_master\" WHERE \"type\" = 'table' AND \"rootpage\" IS NOT NULL;"); return(count != 0); }
public override async Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken)) { ClearAllPools(); using (var masterConnection = _connection.CreateMasterConnection()) { await SqlStatementExecutor.ExecuteNonQueryAsync(masterConnection, CreateDropCommands(), cancellationToken); } }
public override void Create() { using (var masterConnection = _connection.CreateMasterConnection()) { SqlStatementExecutor.ExecuteNonQuery(masterConnection, CreateCreateOperations()); ClearPool(); } Exists(retryOnNotExists: true); }
public override void Delete() { ClearAllPools(); using (var masterConnection = _connection.CreateMasterConnection()) { SqlStatementExecutor .ExecuteNonQuery(masterConnection, CreateDropCommands()); } }
public SqlServerSequenceValueGenerator( [NotNull] SqlStatementExecutor executor, [NotNull] string sequenceName, int blockSize) : base(sequenceName, blockSize) { Check.NotNull(executor, "executor"); _executor = executor; }
public SqlServerSequenceValueGenerator( [NotNull] SqlStatementExecutor executor, [NotNull] string sequenceName, int blockSize) { Check.NotNull(executor, "executor"); Check.NotEmpty(sequenceName, "sequenceName"); _executor = executor; _sequenceName = sequenceName; _blockSize = blockSize; }
public override async Task CreateAsync(CancellationToken cancellationToken = default(CancellationToken)) { using (var masterConnection = _connection.CreateMasterConnection()) { await SqlStatementExecutor .ExecuteNonQueryAsync(masterConnection, CreateCreateOperations(), cancellationToken); ClearPool(); } await ExistsAsync(retryOnNotExists : true, cancellationToken : cancellationToken); }
public NpgsqlSequenceValueGenerator( [NotNull] SqlStatementExecutor executor, [NotNull] NpgsqlSequenceValueGeneratorState generatorState, [NotNull] INpgsqlConnection connection) : base(generatorState) { Check.NotNull(executor, nameof(executor)); Check.NotNull(generatorState, nameof(generatorState)); Check.NotNull(connection, nameof(connection)); _sequenceName = generatorState.SequenceName; _executor = executor; _connection = connection; }
private static void CreateDatabaseSequence(BronieContext context, DataStoreConnection storeConnection) { var executor = new SqlStatementExecutor(); var operations = new SqlServerSequenceValueGeneratorFactory(executor) .GetUpMigrationOperations(context.Model.GetEntityType(typeof(Pegasus)) .GetProperty("Identifier")); var sql = new SqlServerMigrationOperationSqlGenerator(new SqlServerTypeMapper()) .Generate(operations, generateIdempotentSql: false); // TODO: Should be able to get relational connection without cast var connection = ((RelationalConnection)storeConnection).DbConnection; executor.ExecuteNonQuery(connection, sql); }
public SqlServerDataStoreCreator( [NotNull] SqlServerConnection connection, [NotNull] ModelDiffer modelDiffer, [NotNull] SqlServerMigrationOperationSqlGenerator sqlGenerator, [NotNull] SqlStatementExecutor statementExecutor) { Check.NotNull(connection, "connection"); Check.NotNull(modelDiffer, "modelDiffer"); Check.NotNull(sqlGenerator, "sqlGenerator"); Check.NotNull(statementExecutor, "statementExecutor"); _connection = connection; _modelDiffer = modelDiffer; _sqlGenerator = sqlGenerator; _statementExecutor = statementExecutor; }
public NpgsqlDataStoreCreator( [NotNull] NpgsqlEntityFrameworkConnection connection, [NotNull] NpgsqlModelDiffer modelDiffer, [NotNull] NpgsqlMigrationSqlGenerator sqlGenerator, [NotNull] SqlStatementExecutor statementExecutor) { Check.NotNull(connection, "connection"); Check.NotNull(modelDiffer, "modelDiffer"); Check.NotNull(sqlGenerator, nameof(sqlGenerator)); Check.NotNull(statementExecutor, "statementExecutor"); _connection = connection; _modelDiffer = modelDiffer; _sqlGenerator = sqlGenerator; _statementExecutor = statementExecutor; }
public SQLiteDataStoreCreator( [NotNull] SQLiteConnection connection, [NotNull] SqlStatementExecutor executor, [NotNull] SQLiteMigrationOperationSqlGeneratorFactory generatorFactory, [NotNull] SQLiteModelDiffer modelDiffer) { Check.NotNull(connection, "connection"); Check.NotNull(executor, "executor"); Check.NotNull(generatorFactory, "generatorFactory"); Check.NotNull(modelDiffer, "modelDiffer"); _connection = connection; _executor = executor; _generatorFactory = generatorFactory; _modelDiffer = modelDiffer; }
public SqlServerDataStoreCreator( [NotNull] ISqlServerConnection connection, [NotNull] ISqlServerModelDiffer modelDiffer, [NotNull] ISqlServerMigrationSqlGenerator sqlGenerator, [NotNull] SqlStatementExecutor statementExecutor) { Check.NotNull(connection, nameof(connection)); Check.NotNull(modelDiffer, nameof(modelDiffer)); Check.NotNull(sqlGenerator, nameof(sqlGenerator)); Check.NotNull(statementExecutor, nameof(statementExecutor)); _connection = connection; _modelDiffer = modelDiffer; _sqlGenerator = sqlGenerator; _statementExecutor = statementExecutor; }
public SQLiteMigrator( [NotNull] DbContextConfiguration contextConfiguration, [NotNull] HistoryRepository historyRepository, [NotNull] MigrationAssembly migrationAssembly, [NotNull] ModelDiffer modelDiffer, [NotNull] SQLiteMigrationOperationSqlGeneratorFactory ddlSqlGeneratorFactory, [NotNull] SQLiteSqlGenerator dmlSqlGenerator, [NotNull] SqlStatementExecutor sqlExecutor) : base( contextConfiguration, historyRepository, migrationAssembly, modelDiffer, ddlSqlGeneratorFactory, dmlSqlGenerator, sqlExecutor) { }
public SqlServerMigrator( [NotNull] DbContextConfiguration contextConfiguration, [NotNull] HistoryRepository historyRepository, [NotNull] MigrationAssembly migrationAssembly, [NotNull] SqlServerModelDiffer modelDiffer, [NotNull] SqlServerMigrationOperationSqlGeneratorFactory sqlGeneratorFactory, [NotNull] SqlServerSqlGenerator sqlGenerator, [NotNull] SqlStatementExecutor sqlStatementExecutor) : base( contextConfiguration, historyRepository, migrationAssembly, modelDiffer, sqlGeneratorFactory, sqlGenerator, sqlStatementExecutor) { }
public TestMigrator( HistoryRepository historyRepository, MigrationAssembly migrationAssembly, FakeModelDiffer modelDiffer, FakeMigrationOperationSqlGeneratorFactory ddlSqlGeneratorFactory, FakeSqlGenerator dmlSqlGenerator, SqlStatementExecutor sqlExecutor, RecordingDataStoreCreator storeCreator, FakeRelationalConnection connection, ILoggerFactory loggerFactory) : base( historyRepository, migrationAssembly, modelDiffer, ddlSqlGeneratorFactory, dmlSqlGenerator, sqlExecutor, storeCreator, connection, loggerFactory) { }
public SqlServerMigrator( [NotNull] HistoryRepository historyRepository, [NotNull] MigrationAssembly migrationAssembly, [NotNull] SqlServerModelDiffer modelDiffer, [NotNull] SqlServerMigrationOperationSqlGeneratorFactory sqlGeneratorFactory, [NotNull] SqlServerSqlGenerator sqlGenerator, [NotNull] SqlStatementExecutor sqlStatementExecutor, [NotNull] SqlServerDataStoreCreator storeCreator, [NotNull] SqlServerConnection connection, [NotNull] ILoggerFactory loggerFactory) : base( historyRepository, migrationAssembly, modelDiffer, sqlGeneratorFactory, sqlGenerator, sqlStatementExecutor, storeCreator, connection, loggerFactory) { }
protected override bool HasTables() => (int)SqlStatementExecutor.ExecuteScalar(_connection, CreateHasTablesCommand()) != 0;
public NpgsqlSequenceValueGeneratorFactory([NotNull] SqlStatementExecutor executor) { Check.NotNull(executor, nameof(executor)); _executor = executor; }
protected override async Task <bool> HasTablesAsync(CancellationToken cancellationToken = default(CancellationToken)) => (int)(await SqlStatementExecutor .ExecuteScalarAsync(_connection, CreateHasTablesCommand(), cancellationToken)) != 0;
public SqlServerSequenceValueGeneratorFactory([NotNull] SqlStatementExecutor executor) { Check.NotNull(executor, "executor"); _executor = executor; }