public void Execute(ITransformationProvider database) { var columnDefinitions = new List <Column>(); foreach (var builder in _columnBuilders) { columnDefinitions.AddRange(builder()); } if (_createTable) { database.AddTable("[dbo]." + _tableName, columnDefinitions.ToArray()); } else { string queryTableName = "[dbo]." + _tableName; BeforeColumnsAreAddedOrChanged(queryTableName, database); foreach (var column in columnDefinitions) { if (database.ColumnExists(queryTableName, column.Name)) { database.ChangeColumn(queryTableName, column); } else { database.AddColumn(queryTableName, column); } } } foreach (var fk in _foreignKeys) { fk(database); } }
public void ColumnExistsWorks() { Assert.IsFalse(_provider.ColumnExists("gadadadadseeqwe", "eqweqeq")); Assert.IsFalse(_provider.ColumnExists("TestTwo", "eqweqeq")); Assert.IsTrue(_provider.ColumnExists("TestTwo", "Id")); }