<?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="tprabhu">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <!--Insert new encoding profile type for JPAY video feature-->
            INSERT INTO encoding_profile (profile_type, description, `format`) 
            VALUES 
            ('video', 'JPay Video', 'mp4');;
            
            SELECT @newJPayVideoEncodingProfileId:=LAST_INSERT_ID();;

            <!--Insert new video encoding profile type for JPAY video Stereo (354)-->
            INSERT INTO video_encoding_profile (encoding_profile_id, description, `format`, aspect_ratio, resolution, video_source, extension, encoding_engine, channel_type)
            SELECT @newJPayVideoEncodingProfileId, 'JPay Video Stereo' AS description, 'mp4' AS `format`, aspect_ratio, 'ANY' AS resolution, '354' AS video_source, 'mp4' AS extension, encoding_engine, 'stereo' AS channel_type
                FROM video_encoding_profile 
                WHERE encoding_profile_id IN (378)
                GROUP BY aspect_ratio;;

            <!--Insert new video encoding profile type for JPAY video 5.1 surround (355)-->
            INSERT INTO video_encoding_profile (encoding_profile_id, description, `format`, aspect_ratio, resolution, video_source, extension, encoding_engine, channel_type)
            SELECT @newJPayVideoEncodingProfileId, 'JPay Video 5.1 surround' AS description, 'mp4' AS `format`, aspect_ratio, 'ANY' AS resolution, '355' AS video_source, 'mp4' AS extension, encoding_engine, '51surround' AS channel_type
                FROM video_encoding_profile 
                WHERE encoding_profile_id IN (378)
                GROUP BY aspect_ratio;;
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
                DELETE FROM video_encoding_profile WHERE description IN ('JPay Video Stereo', 'JPay Video 5.1 surround');;
                DELETE FROM encoding_profile WHERE description = 'JPay Video';;
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
