protected function applyDatabaseTablePrefix(\DOMElement $databaseElement)
    {
        if (!$databaseElement->hasAttribute('tablePrefix')) {
            return;
        }

        $tablePrefix = $databaseElement->getAttribute('tablePrefix');

        /** @var \DOMElement $tableElement */
        foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
            if (!$tableElement->hasAttribute('name')) {
                // this is probably wrong, but not our problem here - we do not validate the schema
                continue;
            }

            // add a prefixing notice
            $tablePrefixingNoticeComment = $tableElement->ownerDocument->createComment(
                "Table name prefixed with parent database 'tablePrefix'"
            );
            $tableElement->appendChild($tablePrefixingNoticeComment);

            $table = $tableElement->getAttribute('name');
            $tableElement->setAttribute('name', $tablePrefix . $table);
        }
    }