:param diff: The table diff
        :type diff: orator.dbal.table_diff.TableDiff

        :rtype: dict

def _get_foreign_keys_in_altered_table(self, diff):
        """
        :param diff: The table diff
        :type diff: orator.dbal.table_diff.TableDiff

        :rtype: dict
        """
        foreign_keys = diff.from_table.get_foreign_keys()
        column_names = self._get_column_names_in_altered_table(diff)

        for key, constraint in foreign_keys.items():
            changed = False
            local_columns = []
            for column_name in constraint.get_local_columns():
                normalized_column_name = column_name.lower()
                if normalized_column_name not in column_names:
                    del foreign_keys[key]
                    break
                else:
                    local_columns.append(column_names[normalized_column_name])
                    if column_name != column_names[normalized_column_name]:
                        changed = True

            if changed:
                foreign_keys[key] = ForeignKeyConstraint(
                    local_columns,
                    constraint.get_foreign_table_name(),
                    constraint.get_foreign_columns(),
                    constraint.get_name(),
                    constraint.get_options(),
                )

        for constraint in diff.removed_foreign_keys:
            constraint_name = constraint.get_name().lower()
            if constraint_name and constraint_name in foreign_keys:
                del foreign_keys[constraint_name]

        foreign_keys_diff = diff.changed_foreign_keys + diff.added_foreign_keys
        for constraint in foreign_keys_diff:
            constraint_name = constraint.get_name().lower()
            if constraint_name:
                foreign_keys[constraint_name] = constraint
            else:
                foreign_keys[len(foreign_keys)] = constraint

        return foreign_keys