public void Run(long targetVersion) { List <MigrationInfo> migrationsFromAssembly = MigrationFinder.FindMigrations(_targetAssembly); VersionRepository.EnsureSchemaVersionTable(migrationsFromAssembly); List <long> migrationsFromDatabase = VersionRepository.GetAppliedMigrations(); var migrationPlan = new MigrationPlan(migrationsFromDatabase, migrationsFromAssembly, targetVersion); RunMigrations(migrationPlan); }
public void Run(string seedName, string param = null, string migrationGroup = null) { Type seedType = MigrationFinder.FindSeed(_targetAssembly, seedName); Log.Info("Starting seed migration"); Log.Info("Migration group: " + VersionRepository.GetMigrationGroup(migrationGroup)); Log.Info(String.Format("Applying Seed -> [{0}]", seedName)); var migration = (SeedMigration)Activator.CreateInstance(seedType); migration.SetDataClient(_dataClient); migration.Up(param); _dataClient.Commit(); }
private void UpdateCurrentVersion(MigrationPlanStep step) { if (!step.ShouldUpdateVersion) { return; } if (step.Direction == Direction.Up) { VersionRepository.InsertVersion(step.MigrationInfo); } else { VersionRepository.RemoveVersion(step.MigrationInfo); } }
protected virtual void GetCurrentVersion() { _initialVersion = VersionRepository.GetCurrentVersion(); }
public void SetUp() { _client = DBBuilder.GetDataClient(DataProviderNames.OracleManaged); _versionRepository = new VersionRepository(_client); if (_client.TableExists(VersionRepository.VERSION_TABLE_NAME)) { _client.RemoveTable(VersionRepository.VERSION_TABLE_NAME); } if (_client.TableExists(VersionRepository.OLD_VERSION_TABLE_NAME)) { _client.RemoveTable(VersionRepository.OLD_VERSION_TABLE_NAME); } AllMigrations = new[] {M1, M2, M3, M4, M5}.ToList(); }
public void Should_throw_migration_exception_when_cant_create_version_table() { _dataClient.Setup(p => p.TableExists(It.IsAny<string>())).Throws(new Exception("foo")); _versionRepository = new VersionRepository(_dataClient.Object); }