protected function proceedChangeSetsDependsOnRelation()
    {
        $dbHandle = $this->getDatabase()->getDatabaseConnection();

        $tmpTable = Database::TABLE_TMP_DEPENDS_NEEDED;
        $changeSetTable = Database::TABLE_CHANGESET;
        $patchSetTable = Database::TABLE_PATCHSET;

        $query = '
            UPDATE
                ' . $tmpTable . '
                INNER JOIN ' . $changeSetTable . ' AS dependsOnChangeset ON (
                    ' . $tmpTable . '.`identifier` = dependsOnChangeset.`identifier`
                    AND ' . $tmpTable . '.`number` = dependsOnChangeset.`number`
                )
                INNER JOIN ' . $patchSetTable . ' ON (
                    dependsOnChangeset.`id` = ' . $patchSetTable . '.`changeset`
                    AND ' . $patchSetTable . '.`revision` = ' . $tmpTable . '.`revision`
                    AND ' . $patchSetTable . '.`ref` = ' . $tmpTable . '.`ref`
                )
                INNER JOIN ' . $changeSetTable . ' ON (
                    ' . $changeSetTable . '.`id` = ' . $tmpTable . '.`changeset`
                )
            SET
                ' . $changeSetTable . '.`depends_on` = dependsOnChangeset.`id`
            WHERE
                ' . $tmpTable . '.`status` = ' . intval(Database::TMP_DEPENDS_NEEDED_STATUS_DEPENDSON);

        $dbHandle->exec($query);
    }