Package org.databene.jdbacl.model

Examples of org.databene.jdbacl.model.DBTable


  }

  @Test
  public void testSingleIndexColumnReplaced() {
    // given an index consisting of exactly one column which was replaced in a newer index version
    DBTable table = createTableWithColumns("tbl", 2);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1");
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col2");
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here


  }

  @Test
  public void testAllIndexColumnsReplaced() {
    // given an index consisting of two columns which are replaced in a newer index version
    DBTable table = createTableWithColumns("tbl", 4);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1", "col2");
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col3", "col4");
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here

  }
 
  @Test
  public void testIndexColumnAdded() {
    // given a tbale with an index to which one more column has been added
    DBTable table = createTableWithColumns("tbl", 2);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1");
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col1", "col2");
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here

  }

  @Test
  public void testIndexColumnRemoved() {
    // given a table with an index of which one column was removed
    DBTable table = createTableWithColumns("tbl", 2);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1", "col2");
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col1");
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here

public class TableColumnComparatorTest extends AbstractComparatorTest {
 
  @Test
  public void testUnchanged() {
    // given a column that did not change
    DBTable table1 = new DBTable("tbl");
    DBColumn col1 = createIntColumn("col1", table1);
    DBTable table2 = new DBTable("tbl");
    DBColumn col2 = createIntColumn("col1", table2);
    // when performing a comparison
    TableChange tableChange = new TableChange(table1, null);
    new TableColumnComparator(config).compareObjects(col1, col2, tableChange);
    // then the result must be empty
View Full Code Here

  }

  @Test
  public void testTypeChangedFromVarcharToInt() {
    // given a column that of which the type changed from int to varchar(1)
    DBTable table1 = new DBTable("tbl");
    DBColumn col1 = createVarcharColumn("col1", table1);
    DBTable table2 = new DBTable("tbl");
    DBColumn col2 = createIntColumn("col1", table2);
    // when performing a comparison
    TableChange tableChange = new TableChange(table1, null);
    new TableColumnComparator(config).compareObjects(col1, col2, tableChange);
    // then the result must be empty
View Full Code Here

  public void testUnchanged() {
    // given two identical table versions
    Database db1 = new Database("db1", "hsql", "1.5.8", null);
    DBCatalog cat1 = new DBCatalog("cat1", db1);
    DBSchema schema1 = new DBSchema("public", cat1);
    DBTable table1 = createTableWithColumns("tbl", 3);
    schema1.addTable(table1);

    Database db2 = new Database("db1", "hsql", "1.5.8", null);
    DBCatalog cat2 = new DBCatalog("cat2", db2);
    DBSchema schema2 = new DBSchema("public", cat2);
    DBTable table2 = createTableWithColumns("tbl", 3);
    schema2.addTable(table2);
   
    // when comparing the tables
    SchemaChange schemaChange = new SchemaComparator(config).compare(db1, db2);
   
View Full Code Here

  }

  @Test
  public void testColumnsAdded() {
    // given a table which got two additional columns
    DBTable table1 = createTableWithColumns("tbl", 2);
    DBTable table2 = createTableWithColumns("tbl", 4);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be two ColumnCreations
    System.out.println(schemaChange);
View Full Code Here

  }

  @Test
  public void testColumnsRemoved() {
    // given a table of which two columns were removed
    DBTable table1 = createTableWithColumns("tbl", 4);
    DBTable table2 = createTableWithColumns("tbl", 2);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be two ColumnDeletions
    System.out.println(schemaChange);
View Full Code Here

  public NotNullConstraintCreation(DBNotNullConstraint constraint) {
    super(constraint, "created " + constraint.getObjectType(), MadUtil.details(constraint));
  }

  public boolean createCheck(SimpleXMLWriter writer) {
    DBTable table = affectedObject.getTable();
    DBColumn column = table.getColumn(affectedObject.getColumnNames()[0]);
    checkName = "NOT NULL " + table.getName() + "." + column.getName();
    CheckDefinitionUtil.renderNotNullCheck(checkName,
        table.getName(), column.getName(),
        Mad4DB.APP_INFO, "not-null", "migration", writer);
    return true;
  }
View Full Code Here

TOP

Related Classes of org.databene.jdbacl.model.DBTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.