private static function resolveConstrains(
        DriverInterface $driver,
        $tableOID,
        PostgresColumn $column
    ) {
        $query = "SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND "
            . "(consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ?)";

        $constraints = $driver->query($query, [
            $tableOID,
            '(' . $column->name . '%',
            '("' . $column->name . '%',
            '(("' . $column->name . '%',
            '(("' . $column->name . '%',
            //Postgres magic
            $column->name . '::text%',
            '%(' . $column->name . ')::text%'
        ]);

        foreach ($constraints as $constraint) {
            if (preg_match('/ARRAY\[([^\]]+)\]/', $constraint['consrc'], $matches)) {
                $enumValues = explode(',', $matches[1]);
                foreach ($enumValues as &$value) {
                    if (preg_match("/^'?(.*?)'?::(.+)/", trim($value, ' ()'), $matches)) {
                        //In database: 'value'::TYPE
                        $value = $matches[1];
                    }

                    unset($value);
                }

                $column->enumValues = $enumValues;
                $column->constrainName = $constraint['conname'];
                $column->constrained = true;
            }
        }
    }