<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <changeSet id="1" author="anidhi">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

            INSERT INTO encoding_profile (profile_type, description, format) VALUES ('video', 'Amazon International Video', 'mov');;
            SET @last_id_in_encoding_profile_video = LAST_INSERT_ID();;

            INSERT INTO encoding_profile (profile_type, description, format) VALUES ('trailer', 'Amazon International Trailer', 'mov');;
            SET @last_id_in_encoding_profile_trailer = LAST_INSERT_ID();;

            INSERT INTO video_encoding_profile(encoding_profile_id, description, format, aspect_ratio, resolution, video_source, extension, encoding_engine, fps)
            (SELECT @last_id_in_encoding_profile_video, 'Amazon International Video', format, aspect_ratio, resolution, video_source, extension, encoding_engine, fps FROM video_encoding_profile
            WHERE encoding_profile_id = 280);;

            INSERT INTO video_encoding_profile(encoding_profile_id, description, format, aspect_ratio, resolution, video_source, extension, encoding_engine, fps)
            (SELECT @last_id_in_encoding_profile_trailer, 'Amazon International Trailer', format, aspect_ratio, resolution, video_source, extension, encoding_engine, fps FROM video_encoding_profile
            WHERE encoding_profile_id = 281);;

            UPDATE dms_encoding_profile SET filename= 'ORCHARD-{upc}-Full-Mezz-{language}-{country_of_origin}.mov', encoding_profile_id =@last_id_in_encoding_profile_video WHERE dms_master_master_id ='634' AND encoding_profile_id =280;;
            UPDATE dms_encoding_profile SET filename= 'ORCHARD-{upc}-Trailer-Mezz-{language}-{country_of_origin}.mov', encoding_profile_id =@last_id_in_encoding_profile_trailer WHERE dms_master_master_id='634' AND encoding_profile_id =281;;


        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

                UPDATE dms_encoding_profile SET filename= '{release_name_under}_{upc}_en_gb-CONTENT.mov', encoding_profile_id = 280 WHERE dms_master_master_id ='634' AND filename= 'ORCHARD-{upc}-Full-Mezz-{language}-{country_of_origin}.mov';;
                UPDATE dms_encoding_profile SET filename= '{release_name_under}_{upc}_en_gb-PREVIEW.mov', encoding_profile_id = 281 WHERE dms_master_master_id='634' AND filename= 'ORCHARD-{upc}-Trailer-Mezz-{language}-{country_of_origin}.mov';;
                DELETE FROM video_encoding_profile WHERE description IN ("Amazon International Video", "Amazon International Trailer");;
                DELETE FROM encoding_profile WHERE profile_type = "video" AND description = "Amazon International Video";;
                DELETE FROM encoding_profile WHERE profile_type = "trailer" AND description = "Amazon International Trailer";;
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
