// SQLite mixes up cases from the actual declaration and the
// reference definition! It's possible that a table is declared
// in lower case, and the foreign key in upper case. Hence,
// correct the foreign key
TableDefinition referencingTable = getTable(getSchemata().get(0), foreignKeyTable);
TableDefinition referencedTable = getTable(getSchemata().get(0), record.getValueAsString("table"), true);
if (referencedTable != null) {
String uniqueKey =
"pk_" + referencedTable.getName() +
"_" + referencedTable.getColumn(record.getValueAsString("to"), true).getName();
if (referencingTable != null) {
ColumnDefinition referencingColumn = referencingTable.getColumn(foreignKeyColumn);
relations.addForeignKey(foreignKey, uniqueKey, referencingColumn, getSchemata().get(0));
}