private void UpdateSelf() { var migrator = new SchemaMigrationExecutor(_runner, GetMigratorTasks(), SchemaName); using (var t = _db.BeginTransaction()) { if (!_db.DatabaseTools().TableExists(TableName)) { migrator.InstallSchema(); AppendVersion(SchemaName, migrator.LatestVersionAvailable); } else { var latest = GetInstalledVersion(SchemaName); if (latest.IsNullOrEmpty()) { migrator.InstallSchema(); AppendVersion(SchemaName, migrator.LatestVersionAvailable); } else { if (latest != migrator.LatestVersionAvailable) { migrator.MigrateToLatestFrom(latest); AppendVersion(SchemaName, migrator.LatestVersionAvailable); } } } t.Commit(); } }
public void two_versions_of_setup_Db_throws() { _tasks.Add(new InstallerTask()); var s = new SchemaMigrationExecutor(new FakeRunner(), _tasks, "TestSchema"); Assert.Throws <InvalidOperationException>(() => s.InstallSchema()); }
public void setup_latest_version() { _schema.InstallSchema(); Assert.Equal("1.0.2", _sb.ToString()); }