protected function createForeignKeyConstraint(array $constraintOptions, string $fieldName, string $tableName)
    {
        if (is_string($constraintOptions['name'] ?? null)) {
            $constraintName = $constraintOptions;
        } else {
            $constraintName = "ForeignKey_{$tableName}_{$fieldName}";
        }

        if (empty($constraintOptions['referenceTable'])) {
            throw new InvalidArgumentException("Missing option 'referenceTable' for foreign key constraint");
        }

        if (empty($constraintOptions['referenceColumn'])) {
            throw new InvalidArgumentException("Missing option 'referenceColumn' for foreign key constraint");
        }

        return new Constraint\ForeignKey(
            $constraintName,
            [$fieldName],
            $constraintOptions['referenceTable'],
            $constraintOptions['referenceColumn'],
            $constraintOptions['onDeleteRule'] ?? null,
            $constraintOptions['onUpdateRule'] ?? null
        );
    }