private static PersistedVersioning CreateVersioning() { var history = new History("TableName", MockRepository.GenerateStub<IProviderMetadata>()); history.LoadEntry(ExistingTimestampForDefaultModule, string.Empty, ExistingTagForDefaultModule); history.LoadEntry(ExistingTimestampForTestModule, TestModule, ExistingTagForTestModule); return new PersistedVersioning(history); }
private static PersistedVersioning CreateVersioning() { var history = new History(new TableName("TableName", null), A.Fake<IProviderMetadata>()); history.LoadEntry(ExistingTimestampForDefaultModule, string.Empty, ExistingTagForDefaultModule); history.LoadEntry(ExistingTimestampForTestModule, TestModule, ExistingTagForTestModule); return new PersistedVersioning(history); }
public SqlAggregateMigrationGenerator(Server server, Database database, GeneratorOptions options) : base(server, database, options) { var providerLocator = new ProviderLocator(new ProviderFactory()); // CLEAN: use DI container ProviderInfo provider = providerLocator.GetExactly(DbPlatform.SqlServer2008); var versioningTableName = new TableName(options.VersioningTableName, options.VersioningTableSchema); _history = new History(versioningTableName, provider.Metadata); IDbConnection connection = server.ConnectionContext.SqlConnectionObject; connection.Open(); connection.ChangeDatabase(Database.Name); // ATTENTION: possibly has side-effects try { _history.Load(connection, null); } finally { connection.Close(); } }
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; }
internal PersistedVersioning(History history) { _history = history; }