private PersistedVersioning GetPersistedVersioning(IDbConnection connection, IDbTransaction transaction, IDbCommandExecutor executor) { if (_persistedVersioning == null) { var history = new History(_versioningTableName, _providerMetadata); if (!_versioningTableExists.Value) { Debug.Assert(connection != null, "At this point, an upgrade of the versioning table is requested. This always takes part of a running migration step and therefore already has an associated connection (and possibly a transaction)."); // execute the boostrap migration to create the versioning table var step = new BootstrapMigrationStep(new BootstrapMigration(_versioningTableName), _provider, _providerMetadata); step.Execute(connection, transaction, MigrationDirection.Up, executor); _versioningTableExists = new Lazy <bool>(() => true); // now, the versioning table exists } else { // load the existing entries from the versioning table IDbConnection c = connection ?? _connectionFactory.OpenConnection(_connectionInfo); try { history.Load(c, transaction); } finally { if (connection == null) // we had to open a connection ourselves { c.Dispose(); } } } _persistedVersioning = new PersistedVersioning(history); } Debug.Assert(_persistedVersioning != null); return(_persistedVersioning); }
internal void UpdateToInclude(IEnumerable <IMigrationMetadata> containedMigrations, IDbConnection connection, IDbTransaction transaction) { IDbCommandExecutor executor; using ((executor = _sqlDispatcher.CreateExecutor("CustomBootstrapping")) as IDisposable) { PersistedVersioning versioning = GetPersistedVersioning(connection, transaction, executor); versioning.UpdateToInclude(containedMigrations, connection, transaction, executor); } }
private PersistedVersioning GetPersistedVersioning(IDbConnection connection, IDbTransaction transaction, IDbCommandExecutor executor) { if (_persistedVersioning == null) { var history = new History(_versioningTableName, _configuration.ProviderInfo.Metadata); if (!_versioningTableExists.Value) { Debug.Assert(connection != null, "At this point, an upgrade of the versioning table is requested. This always takes part of a running migration step and therefore already has an associated connection (and possibly a transaction)."); // execute the boostrap migration to create the versioning table var step = new BootstrapMigrationStep(new BootstrapMigration(_versioningTableName), null); step.Execute(_configuration.ProviderInfo, connection, transaction, MigrationDirection.Up, executor); _versioningTableExists = new Lazy<bool>(() => true); // now, the versioning table exists } else { // load the existing entries from the versioning table IDbConnection c = connection ?? _configuration.OpenConnection(); try { history.Load(c, transaction); } finally { if (connection == null) // we had to open a connection ourselves { c.Dispose(); } } } _persistedVersioning = new PersistedVersioning(history); } Debug.Assert(_persistedVersioning != null); return _persistedVersioning; }
public void Update(IScheduledMigrationMetadata metadata, IDbConnection connection, IDbTransaction transaction, IDbCommandExecutor commandExecutor) { PersistedVersioning versioning = GetPersistedVersioning(connection, transaction, commandExecutor); versioning.Update(metadata, connection, transaction, commandExecutor); }