ALTER TABLE cms__file_static ADD data_synced BOOLEAN
    AS (JSON_UNQUOTE(data->"$.synced")) STORED;

-- Droppolni minden partnerhez tartozó view_all_mediat, illetve ezt felülírni
CREATE OR REPLACE
ALGORITHM = UNDEFINED VIEW `view__all_media` AS (
select
    `f`.`fileID` AS `mediaID`,
    `fs`.`type` AS `mediaType`,
    `fs`.`socialChannel` AS `socialChannel`,
    `fs`.`mime` AS `mime`,
    `f`.`name` AS `mediaName`,
    `f`.`url` AS `url`,
    `fp`.`url` AS `previewFileUrl`,
    `fs`.`size` AS `size`,
    `fs`.`data_width` AS `width`,
    `fs`.`data_height` AS `height`,
    `fs`.`data_ratio` AS `ratio`,
    `fs`.`data_synced` AS `synced`,
    `fs`.`canvaId` AS `canvaId`,
    `fs`.`systemType` AS `systemType`,
    `f`.`status` AS `status`,
    `f`.`userID` AS `userID`,
    `f`.`createDate` AS `createDate`,
    `f`.`modifyDate` AS `modifyDate`,
    `fs`.`realPath` AS `realPath`,
    'file' AS `mainMediaType`
from
    ((`cms__file` `f`
join `cms__file_static` `fs` on
    (((`fs`.`fileID` = `f`.`fileID`)
        and (`fs`.`type` <> 'preview'))))
left join `cms__file` `fp` on
    ((`fp`.`fileID` = `fs`.`previewFileID`))))
union (
select
`c`.`carouselID` AS `mediaID`,
'carousel' AS `mediaType`,
`c`.`socialChannel` AS `socialChannel`,
'carousel' AS `mime`,
`c`.`name` AS `mediaName`,
`c`.`url` AS `url`,
NULL AS `previewFileUrl`,
NULL AS `size`,
NULL AS `width`,
NULL AS `height`,
NULL AS `ratio`,
NULL AS `synced`,
NULL AS `canvaId`,
`c`.`systemType` AS `systemType`,
`c`.`status` AS `status`,
`c`.`userID` AS `userID`,
`c`.`createDate` AS `createDate`,
`c`.`modifyDate` AS `modifyDate`,
NULL AS `realPath`,
'carousel' AS `mainMediaType`
from
`smd__carousel` `c`)