protected function migrateAccountRolesUp()
    {
        if (!$this->sm->tablesExist(['typo3_flow_security_account'])) {
            return;
        }
        $rolesSql = array();
        $accountRolesSql = array();
        $rolesToMigrate = array();

        $accountsResult = $this->connection->executeQuery('SELECT DISTINCT(roles) FROM typo3_flow_security_account');
        while ($accountIdentifierAndRoles = $accountsResult->fetch(\PDO::FETCH_ASSOC)) {
            $roleIdentifiers = unserialize($accountIdentifierAndRoles['roles']);
            foreach ($roleIdentifiers as $roleIdentifier) {
                $rolesToMigrate[$roleIdentifier] = true;
            }
        }

        $roleIdentifierMap = $this->getRoleIdentifierMap($rolesToMigrate);

        $accountsResult = $this->connection->executeQuery('SELECT persistence_object_identifier, roles FROM typo3_flow_security_account');
        while ($accountIdentifierAndRoles = $accountsResult->fetch(\PDO::FETCH_ASSOC)) {
            $accountIdentifier = $accountIdentifierAndRoles['persistence_object_identifier'];
            $roleIdentifiers = unserialize($accountIdentifierAndRoles['roles']);
            foreach ($roleIdentifiers as $roleIdentifier) {
                $roleIdentifier = $roleIdentifierMap[$roleIdentifier];
                $rolesSql[$roleIdentifier] = "INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES (" . $this->connection->quote($roleIdentifier) . ", 'policy')";
                $accountRolesSql[] = "INSERT INTO typo3_flow_security_account_roles_join (flow_security_account, flow_policy_role) VALUES (" . $this->connection->quote($accountIdentifier) . ", " . $this->connection->quote($roleIdentifier) . ")";
            }
        }

        foreach ($rolesSql as $sql) {
            $this->addSql($sql);
        }
        foreach ($accountRolesSql as $sql) {
            $this->addSql($sql);
        }
    }