private function ensureOrderColumnExists()
    {
        $attributes = $this
            ->connection
            ->createQueryBuilder()
            ->select('metamodel.tableName', 'attribute.colname')
            ->from('tl_metamodel_attribute', 'attribute')
            ->leftJoin('attribute', 'tl_metamodel', 'metamodel', 'metamodel.id=attribute.pid')
            ->where('attribute.type=:type')
            ->setParameter('type', 'file')
            ->andWhere('attribute.file_multiple=:multiple')
            ->setParameter('multiple', '1')
            ->execute();

        while ($row = $attributes->fetch(\PDO::FETCH_OBJ)) {
            if ($this->fieldExists($row->colname . '__sort', $row->tableName)) {
                continue;
            }
            $this
                ->connection
                ->exec(
                    \sprintf(
                        'ALTER TABLE %1$s ADD COLUMN %2$s__sort %3$s',
                        $row->tableName,
                        $row->colname,
                        'blob NULL'
                    )
                );
        }
    }