public function postDown(Schema $schema)
    {
        if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) {
            return;
        }
        $resourcesResult = $this->connection->executeQuery('SELECT DISTINCT resourcepointer FROM typo3_flow_resource_resource');
        while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) {
            $this->connection->executeQuery(
                'INSERT INTO typo3_flow_resource_resourcepointer (hash) VALUES (?)',
                array($resourceInfo['resourcepointer'])
            );

            $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'][0] . '/' . $resourceInfo['resourcepointer'][1] . '/' . $resourceInfo['resourcepointer'][2] . '/' . $resourceInfo['resourcepointer'][3] . '/' . $resourceInfo['resourcepointer'];
            if (!file_exists($resourcePathAndFilename)) {
                $this->write(sprintf('Error while migrating database for the old resource management: the resource file "%s" was not found.', $resourcePathAndFilename));
                continue;
            }
            $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'];
            $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename);
            if ($result === false) {
                $this->write(sprintf('Could not move the data file of resource "%s" from its location at %s to the legacy location %s.', $resourceInfo['resourcepointer'], $resourcePathAndFilename, $newResourcePathAndFilename));
            }
            Files::removeEmptyDirectoriesOnPath(dirname($resourcePathAndFilename));
        }

        $this->connection->exec('UPDATE typo3_flow_resource_resource SET fileextension =  SUBSTRING_INDEX(filename, \'.\', -1)');
        $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ADD CONSTRAINT typo3_flow_resource_resource_ibfk_1 FOREIGN KEY (resourcepointer) REFERENCES typo3_flow_resource_resourcepointer (hash)');
    }
public function postDown(Schema $schema)
    {
        if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) {
            return;
        }
        $resourcesResult = $this->connection->executeQuery('SELECT DISTINCT resourcepointer FROM typo3_flow_resource_resource');
        while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) {
            $this->connection->executeQuery(
                'INSERT INTO typo3_flow_resource_resourcepointer (hash) VALUES (?)',
                array($resourceInfo['resourcepointer'])
            );

            $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'][0] . '/' . $resourceInfo['resourcepointer'][1] . '/' . $resourceInfo['resourcepointer'][2] . '/' . $resourceInfo['resourcepointer'][3] . '/' . $resourceInfo['resourcepointer'];
            if (!file_exists($resourcePathAndFilename)) {
                $this->write(sprintf('Error while migrating database for the old resource management: the resource file "%s" was not found.', $resourcePathAndFilename));
                continue;
            }
            $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'];
            $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename);
            if ($result === false) {
                $this->write(sprintf('Could not move the data file of resource "%s" from its location at %s to the legacy location %s.', $resourceInfo['resourcepointer'], $resourcePathAndFilename, $newResourcePathAndFilename));
            }
            Files::removeEmptyDirectoriesOnPath(dirname($resourcePathAndFilename));
        }

        $this->connection->exec('UPDATE typo3_flow_resource_resource SET fileextension =  SUBSTRING_INDEX(filename, \'.\', -1)');
        $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ADD CONSTRAINT typo3_flow_resource_resource_ibfk_1 FOREIGN KEY (resourcepointer) REFERENCES typo3_flow_resource_resourcepointer (hash)');
    }
public function postDown ( Schema $ schema ) { if ( ! $ this -> sm -> tablesExist ( [ 'typo3_flow_resource_resource' ] ) ) { return ; } $ resourcesResult = $ this -> connection -> executeQuery ( 'SELECT DISTINCT resourcepointer FROM typo3_flow_resource_resource' ) ; while ( $ resourceInfo = $ resourcesResult -> fetch ( \ PDO :: FETCH_ASSOC ) ) { $ this -> connection -> executeQuery ( 'INSERT INTO typo3_flow_resource_resourcepointer (hash) VALUES (?)' , array ( $ resourceInfo [ 'resourcepointer' ] ) ) ; $ resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $ resourceInfo [ 'resourcepointer' ] [ 0 ] . '/' . $ resourceInfo [ 'resourcepointer' ] [ 1 ] . '/' . $ resourceInfo [ 'resourcepointer' ] [ 2 ] . '/' . $ resourceInfo [ 'resourcepointer' ] [ 3 ] . '/' . $ resourceInfo [ 'resourcepointer' ] ; if ( ! file_exists ( $ resourcePathAndFilename ) ) { $ this -> write ( sprintf ( 'Error while migrating database for the old resource management: the resource file "%s" was not found.' , $ resourcePathAndFilename ) ) ; continue ; } $ newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $ resourceInfo [ 'resourcepointer' ] ; $ result = @ rename ( $ resourcePathAndFilename , $ newResourcePathAndFilename ) ; if ( $ result === false ) { $ this -> write ( sprintf ( 'Could not move the data file of resource "%s" from its location at %s to the legacy location %s.' , $ resourceInfo [ 'resourcepointer' ] , $ resourcePathAndFilename , $ newResourcePathAndFilename ) ) ; } Files :: removeEmptyDirectoriesOnPath ( dirname ( $ resourcePathAndFilename ) ) ; } $ this -> connection -> exec ( 'UPDATE typo3_flow_resource_resource SET fileextension =  SUBSTRING_INDEX(filename, \'.\', -1)' ) ; $ this -> connection -> exec ( 'ALTER TABLE typo3_flow_resource_resource ADD CONSTRAINT typo3_flow_resource_resource_ibfk_1 FOREIGN KEY (resourcepointer) REFERENCES typo3_flow_resource_resourcepointer (hash)' ) ; }
Move resource files back to the old locations and adjust records.

@param Schema $schema
@return void
Move resource files back to the old locations and adjust records .