Skip to content

Commit

Permalink
Prefix symmetric indexes with sync.table.prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Aug 30, 2011
1 parent 9dc0721 commit f4c59ac
Showing 1 changed file with 13 additions and 8 deletions.
Expand Up @@ -908,8 +908,8 @@ protected boolean prefixConfigDatabase(Database targetTables) {
boolean createTables = false;
for (Table table : tables) {
table.setName(tblPrefix + table.getName());
fixForeignKeys(table, tblPrefix, false);

fixForeignKeys(table, tblPrefix);
fixIndexes(table, tblPrefix);
if (getTable(getDefaultCatalog(), getDefaultSchema(), table.getName(), false) == null) {
createTables = true;
}
Expand Down Expand Up @@ -1069,19 +1069,24 @@ protected Database merge(Database...databases) {
return database;
}

protected void fixForeignKeys(Table table, String tablePrefix, boolean clone)
protected void fixForeignKeys(Table table, String tablePrefix)
throws CloneNotSupportedException {
ForeignKey[] keys = table.getForeignKeys();
for (ForeignKey key : keys) {
if (clone) {
table.removeForeignKey(key);
key = (ForeignKey) key.clone();
table.addForeignKey(key);
}
String prefixedName = tablePrefix + key.getForeignTableName();
key.setForeignTableName(prefixedName);
key.setName(tablePrefix + key.getName());
}
}

protected void fixIndexes(Table table, String tablePrefix) throws CloneNotSupportedException {
Index[] indexes = table.getIndices();
if (indexes != null) {
for (Index index : indexes) {
String prefixedName = tablePrefix + index.getName();
index.setName(prefixedName);
}
}
}

public Platform getPlatform() {
Expand Down

0 comments on commit f4c59ac

Please sign in to comment.