protected function updateMediaInContent(Database $db)
    {
        $this->write('  + Updating orchestra_media attributes');
        $configMediaFieldType = $this->container->getParameter('open_orchestra_migration.media_configuration');
        $this->checkExecute($db->execute(
            $this->getJSFunctions() . '
            var contentMediaFieldType = '.json_encode($configMediaFieldType['content_media_field_type']).';
            db.content.find({}).snapshot().forEach(function(content) {
                var updated = false;

                for (var attributeName in content.attributes) {
                    if (
                        content.attributes.hasOwnProperty(attributeName) &&
                        contentMediaFieldType.indexOf(content.attributes[attributeName].type) > -1 &&
                        content.attributes[attributeName].hasOwnProperty("value")
                    ) {
                        var alt = "";
                        if (
                            null !== content.attributes[attributeName].value.id &
                            "" !== content.attributes[attributeName].value.id
                        ) {
                            alt = getMediaAlt(content.attributes[attributeName].value.id, content.language);
                        }
                        content.attributes[attributeName].value.alt = alt;
                        content.attributes[attributeName].value.legend = "";
                        updated = true;
                    }
                }

                if (updated) {
                    db.content.update({_id: content._id}, content);
                }

            });
        '));
    }