if (schemaTransaction.getType() == TransactionType.INSERT) {
if (schemaTransaction.getTarget().getClass() == Database.class) {
Database database = (Database) schemaTransaction.getTarget();
sql = "INSERT INTO `database` (`database`.`NAME`) VALUES ('" + TransactionConverter.escapeSQL(database.getName()) + "');";
} else if (schemaTransaction.getTarget().getClass() == Table.class) {
Table table = (Table) schemaTransaction.getTarget();
sql = "INSERT INTO `table` (`table`.`NAME`, `table`.`PRIMARY_KEYS`, `table`.`DATABASE_ID`) VALUES ('" + TransactionConverter.escapeSQL(table.getName()) + "', '" + TransactionConverter.escapeSQL(table.getPk()) + "', " + table.getDatabase().getId() + ");";
} else if (schemaTransaction.getTarget().getClass() == Column.class) {
Column cs = (Column) schemaTransaction.getTarget();
sql = "INSERT INTO `column` (`column`.`NAME`, `column`.`ORDINAL_POSITION`, `column`.`DATA_TYPE`, `column`.`SIZE`, `column`.`REPLICABLE`, `column`.`TABLE_ID`) VALUES('" + TransactionConverter.escapeSQL(cs.getName()) + "', " + cs.getOrdinalPosition() + ", '" + TransactionConverter.escapeSQL(cs.getDataType()) + "', " + cs.getSize() + ", " + cs.isReplicable() + ", " + cs.getTable().getId() + ");";
}
} else if (schemaTransaction.getType() == TransactionType.UPDATE) {
if (schemaTransaction.getTarget().getClass() == Table.class) {
Table table = (Table) schemaTransaction.getTarget();
sql = "UPDATE `table` SET `table`.`PRIMARY_KEYS` = '" + table.getPk() + "' WHERE `table`.`ID` = " + table.getId() + ";";
} else if (schemaTransaction.getTarget().getClass() == Column.class) {
Column column = (Column) schemaTransaction.getTarget();
sql = "UPDATE `column` SET `column`.`ORDINAL_POSITION` = " + column.getOrdinalPosition() + ", `column`.`DATA_TYPE` = '" + column.getDataType() + "', `column`.`SIZE` = " + column.getSize() + " WHERE `column`.`ID` = " + column.getId() + ";";
}
} else if (schemaTransaction.getType() == TransactionType.DELETE) {
if (schemaTransaction.getTarget().getClass() == Database.class) {
Database database = (Database) schemaTransaction.getTarget();
sql = "DELETE FROM `database` WHERE `database`.`ID` = " + database.getId() + ";";
} else if (schemaTransaction.getTarget().getClass() == Table.class) {
Table table = (Table) schemaTransaction.getTarget();
sql = "DELETE FROM `table` WHERE `table`.`ID` = " + table.getId() + ";";
} else if (schemaTransaction.getTarget().getClass() == Column.class) {
Column column = (Column) schemaTransaction.getTarget();
sql = "DELETE FROM `column` WHERE `column`.`ID` = " + column.getId() + ";";
}
}