Examples of SchemaChange


Examples of org.apache.cassandra.transport.Event.SchemaChange

        events.add(TopologyChange.movedNode(FBUtilities.getBroadcastAddress(), 42));

        events.add(StatusChange.nodeUp(FBUtilities.getBroadcastAddress(), 42));
        events.add(StatusChange.nodeDown(FBUtilities.getBroadcastAddress(), 42));

        events.add(new SchemaChange(SchemaChange.Change.CREATED, "ks"));
        events.add(new SchemaChange(SchemaChange.Change.UPDATED, "ks"));
        events.add(new SchemaChange(SchemaChange.Change.DROPPED, "ks"));

        events.add(new SchemaChange(SchemaChange.Change.CREATED, SchemaChange.Target.TABLE, "ks", "table"));
        events.add(new SchemaChange(SchemaChange.Change.UPDATED, SchemaChange.Target.TABLE, "ks", "table"));
        events.add(new SchemaChange(SchemaChange.Change.DROPPED, SchemaChange.Target.TABLE, "ks", "table"));

        if (version >= 3)
        {
            events.add(new SchemaChange(SchemaChange.Change.CREATED, SchemaChange.Target.TYPE, "ks", "type"));
            events.add(new SchemaChange(SchemaChange.Change.UPDATED, SchemaChange.Target.TYPE, "ks", "type"));
            events.add(new SchemaChange(SchemaChange.Change.DROPPED, SchemaChange.Target.TYPE, "ks", "type"));
        }

        for (Event ev : events)
        {
            ByteBuf buf = Unpooled.buffer(ev.serializedSize(version));
View Full Code Here

Examples of org.apache.cassandra.transport.Event.SchemaChange

        events.add(TopologyChange.movedNode(FBUtilities.getBroadcastAddress(), 42));

        events.add(StatusChange.nodeUp(FBUtilities.getBroadcastAddress(), 42));
        events.add(StatusChange.nodeDown(FBUtilities.getBroadcastAddress(), 42));

        events.add(new SchemaChange(SchemaChange.Change.CREATED, "ks"));
        events.add(new SchemaChange(SchemaChange.Change.UPDATED, "ks"));
        events.add(new SchemaChange(SchemaChange.Change.DROPPED, "ks"));

        events.add(new SchemaChange(SchemaChange.Change.CREATED, SchemaChange.Target.TABLE, "ks", "table"));
        events.add(new SchemaChange(SchemaChange.Change.UPDATED, SchemaChange.Target.TABLE, "ks", "table"));
        events.add(new SchemaChange(SchemaChange.Change.DROPPED, SchemaChange.Target.TABLE, "ks", "table"));

        if (version >= 3)
        {
            events.add(new SchemaChange(SchemaChange.Change.CREATED, SchemaChange.Target.TYPE, "ks", "type"));
            events.add(new SchemaChange(SchemaChange.Change.UPDATED, SchemaChange.Target.TYPE, "ks", "type"));
            events.add(new SchemaChange(SchemaChange.Change.DROPPED, SchemaChange.Target.TYPE, "ks", "type"));
        }

        for (Event ev : events)
        {
            ByteBuf buf = Unpooled.buffer(ev.serializedSize(version));
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

  }
 
  // interface -------------------------------------------------------------------------------------------------------

  public SchemaChange compare(Database db1, Database db2) {
    SchemaChange change = new SchemaChange(config);
    compareTables(db1, db2, change);
    if (!config.isIgnoringSequences())
      compareSequences(db1, db2, change);
    compareTriggers(db1, db2, change);
    comparePackages(db1, db2, change);
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

public class TableCreationValuatorTest {

  @Test
  public void testNewMandatoryFkInOldTableReferencesNewTable() {
    // given a new table which will be referenced by a new mandatory FK in an old table
    SchemaChange schemaChange = createSchemaChange(false);
    // when performing check
    new TableCreationValuator().process(schemaChange);
    // then expect AUGMENTAION
    assertEquals(ChangeSeverity.AUGMENTATION, schemaChange.getSubChange(TableCreation.class, "referee").getSeverity());
    assertEquals(ChangeSeverity.AUGMENTATION, schemaChange.getSubChange(ForeignKeyConstraintCreation.class, "new_fk").getSeverity());
  }
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

  }

  @Test
  public void testNewOptionalFkInOldTableReferencesNewTable() {
    // given a new table which will be referenced by a new optional FK in an old table
    SchemaChange schemaChange = createSchemaChange(true);
    // when performing check
    new TableCreationValuator().process(schemaChange);
    // then expect EXTENSION
    assertEquals(ChangeSeverity.EXTENSION, schemaChange.getSubChange(TableCreation.class, "referee").getSeverity());
    assertEquals(ChangeSeverity.RESTRICTION, schemaChange.getSubChange(ForeignKeyConstraintCreation.class, "new_fk").getSeverity());
  }
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

  @Test
  public void testUnchanged() {
    // given two identical table versions
    DBTable table1 = createTableWithColumns("tbl", 3);
    DBTable table2 = createTableWithColumns("tbl", 3);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be empty
    System.out.println(schemaChange);
    List<StructuralChange<?>> tableChanges = schemaChange.getSubChanges();
    assertEquals(0, tableChanges.size());
  }
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

    assertEquals(ChangeSeverity.EXTENSION, schemaChange.getSubChange(TableCreation.class, "referee").getSeverity());
    assertEquals(ChangeSeverity.RESTRICTION, schemaChange.getSubChange(ForeignKeyConstraintCreation.class, "new_fk").getSeverity());
  }

  private SchemaChange createSchemaChange(boolean nullableFk) {
    SchemaChange schemaChange = new SchemaChange(new ComparisonConfig(null, null, null));
    DBTable refereeTable = new DBTable("referee");
    DBTable refererTable = new DBTable("referer");
    DBColumn fkColumn = new DBColumn("ref", refererTable, DBDataType.getInstance(Types.INTEGER, "int"));
    fkColumn.setNullable(nullableFk);
    refereeTable.addColumn(fkColumn);
    schemaChange.addSubChange(new TableCreation(refereeTable));
    DBForeignKeyConstraint fk = new DBForeignKeyConstraint("new_fk", true, refererTable, new String[] { "ref" }, refereeTable, new String[] { "id" });
    schemaChange.addSubChange(new ForeignKeyConstraintCreation(fk));
    return schemaChange;
  }
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

  @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);
    List<StructuralChange<?>> tableChanges = assertSingleSubChangeAndGetItsSubChanges(TableChange.class, DBTable.class, "tbl", ChangeSeverity.EXTENSION, schemaChange);
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

  @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);
    List<StructuralChange<?>> tableChanges = assertSingleSubChangeAndGetItsSubChanges(TableChange.class, DBTable.class, "tbl", ChangeSeverity.DELETION, schemaChange);
View Full Code Here

Examples of org.databene.mad4db.cmd.SchemaChange

  @Test
  public void testColumnOrderChanged() {
    // given a table in which the column order was reversed
    DBTable table1 = createTableWithColumns("tbl", 3);
    DBTable table2 = createTableWithColumns("tbl", "col3", "col2", "col1");
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be a ColumnOrderChange
    System.out.println(schemaChange);
    List<StructuralChange<?>> tableChanges = assertSingleSubChangeAndGetItsSubChanges(TableChange.class, DBTable.class, "tbl", ChangeSeverity.REORGANIZATION, schemaChange);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.