docs: void addForeignKey(Constraint c) {
  
          checkCreateForeignKey(c);
  
          Constraint uniqueConstraint =
              c.core.mainTable.getUniqueConstraintForColumns(c.core.mainCols,
                  c.core.refCols);
          Index mainIndex = uniqueConstraint.getMainIndex();
  
          uniqueConstraint.checkReferencedRows(session, table, c.core.refCols);
  
          int offset = database.schemaManager.getTableIndex(table);
          boolean isForward = c.core.mainTable.getSchemaName()
                              != table.getSchemaName();
  
          if (offset != -1
                  && offset
                     < database.schemaManager.getTableIndex(c.core.mainTable)) {
              isForward = true;
          }
  
          HsqlName indexName = database.nameManager.newAutoName("IDX",
              table.getSchemaName(), table.getName(), SchemaObject.INDEX);
          Index refIndex = table.createIndexStructure(indexName, c.core.refCols,
              null, null, false, false, true, isForward);
          HsqlName mainName = database.nameManager.newAutoName("REF",
              c.getName().name, table.getSchemaName(), table.getName(),
              SchemaObject.INDEX);
  
          c.core.uniqueName = uniqueConstraint.getName();
          c.core.mainName   = mainName;
          c.core.mainIndex  = mainIndex;
          c.core.refTable   = table;
          c.core.refName    = c.getName();
          c.core.refIndex   = refIndex;
          c.isForward       = isForward;
  
          Table tn = table.moveDefinition(session, table.tableType, null, c,
                                          refIndex, -1, 0, emptySet, emptySet);
  
          tn.moveData(session, table, -1, 0);
          c.core.mainTable.addConstraint(new Constraint(mainName, c));
          database.schemaManager.addSchemaObject(c);
          database.persistentStoreCollection.releaseStore(table);
          setNewTableInSchema(tn);
          updateConstraints(tn, emptySet);
          database.schemaManager.recompileDependentObjects(tn);
  
          table = tn;
      }