<?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="n-kumar">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

        <!--Insert new encoding profile for Dish MPEG2 Transport Stream -->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('video', 'Dish MPEG2 Transport Stream', 'ts');;
            SET @last_id_in_encoding_profile_video = 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, 'Dish MPEG2 Transport Stream', 'ts', aspect_ratio, resolution, '338', 'ts', encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 330);;

        <!--Insert new encoding profile for Bell MXF-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('video', 'Bell MXF', 'mxf');;
            SET @last_id_in_encoding_profile_video = 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, 'Bell MXF', 'mxf', aspect_ratio, resolution, '339', 'mxf', encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 330);;

        <!--Insert new encoding profile for 29.97 Broadcast Feature-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('video', '29.97 Broadcast Feature', 'mov');;
            SET @last_id_in_encoding_profile_video = 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, '29.97 Broadcast Feature', format, aspect_ratio, resolution, '341', extension, encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 330);;

        <!--Insert new encoding profile for Clean Asset Feature-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('video', 'Clean Asset Feature', 'mov');;
            SET @last_id_in_encoding_profile_video = 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, 'Clean Asset Feature', format, aspect_ratio, resolution, '343', extension, encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 330);;

        <!--Insert new encoding profile for 4K / UHD Feature-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('video', '4K / UHD Feature', 'mov');;
            SET @last_id_in_encoding_profile_video = 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, '4K / UHD Feature', format, aspect_ratio, resolution, '345', extension, encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 330);;
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

                DELETE FROM video_encoding_profile WHERE description IN ("Dish MPEG2 Transport Stream", "Bell MXF", "29.97 Broadcast Feature", "Clean Asset Feature", "4K / UHD Feature");;

                DELETE FROM encoding_profile WHERE profile_type = "video" AND description IN("Dish MPEG2 Transport Stream", "Bell MXF", "29.97 Broadcast Feature", "Clean Asset Feature", "4K / UHD Feature");;
            </sql>
        </rollback>
    </changeSet>
    <changeSet id="2" author="n-kumar">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

        <!--Insert new encoding profile for Bell MXF Trailer-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('trailer', 'Bell MXF Trailer', 'mxf');;
            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_trailer, 'Bell MXF Trailer', 'mxf', aspect_ratio, resolution, '340', 'mxf', encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 331);;

        <!--Insert new encoding profile for 29.97 Broadcast Trailer-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('trailer', '29.97 Broadcast 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_trailer, '29.97 Broadcast Trailer', format, aspect_ratio, resolution, '342', extension, encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 331);;

        <!--Insert new encoding profile for Clean Asset Trailer-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('trailer', 'Clean Asset 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_trailer, 'Clean Asset Trailer', format, aspect_ratio, resolution, '344', extension, encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 331);;

        <!--Insert new encoding profile for 4K / UHD Trailer-->
            INSERT INTO encoding_profile (profile_type, description, format)
            VALUES ('trailer', '4K / UHD 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_trailer, '4K / UHD Trailer', format, aspect_ratio, resolution, '346', extension, encoding_engine, fps FROM video_encoding_profile WHERE encoding_profile_id = 331);;
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

                DELETE FROM video_encoding_profile WHERE description IN ("Bell MXF Trailer" , "29.97 Broadcast Trailer", "Clean Asset Trailer", "4K / UHD Trailer");;

                DELETE FROM encoding_profile WHERE profile_type = "trailer" AND description IN ("Bell MXF Trailer" , "29.97 Broadcast Trailer", "Clean Asset Trailer", "4K / UHD Trailer");;
            </sql>
        </rollback>
    </changeSet>
    <changeSet id="3" author="n-kumar">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

        <!--Insert new encoding profile for 23.98 Caption File and 29.97 DF Caption File (hour 1)-->
            INSERT INTO encoding_profile (profile_type, description, format) VALUES
            ('caption', '23.98 Caption File', 'caption_2398'),
            ('caption', '29.97 DF Caption File (hour 1)', 'df_caption_2997');;

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

                DELETE FROM encoding_profile WHERE profile_type = "caption" AND description IN ("23.98 Caption File", "29.97 DF Caption File (hour 1)");;
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
