<?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">
        <!--Alter encoding_profile.profile_type` to add new profile types-->
            ALTER TABLE encoding_profile CHANGE profile_type profile_type ENUM('audio','image','metadata','video','video_image','video_chapter_image','trailer','caption','subtitles','forced_subtitles','trigger','subtitle_srt','subtitle_itt','forced_subtitle_itt','forced_subtitle_srt');;

        <!--Add 4 new EPs with these profile_type type-->
           INSERT INTO encoding_profile (profile_type, description, format) VALUES 
           ('subtitle_srt', 'Subtitle srt', 'subtitles_srt'),
           ('subtitle_itt', 'Subtitle itt', 'subtitles_itt'),
           ('forced_subtitle_itt', 'Forced Subtitle itt', 'forced_subtitles_itt'),
           ('forced_subtitle_srt', 'Forced Subtitle srt', 'forced_subtitles_srt');;
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <!--remove added 4 new EPs with those profile_type type-->
                 DELETE FROM encoding_profile WHERE profile_type = "subtitle_srt" AND description = "Subtitle srt";;
                 DELETE FROM encoding_profile WHERE profile_type = "subtitle_itt" AND description = "Subtitle itt";;
                 DELETE FROM encoding_profile WHERE profile_type = "forced_subtitle_itt" AND description = "Forced Subtitle itt";;
                 DELETE FROM encoding_profile WHERE profile_type = "forced_subtitle_srt" AND description = "Forced Subtitle srt";;

            <!--Alter encoding_profile.profile_type` to remove added profile types-->
                ALTER TABLE encoding_profile CHANGE profile_type profile_type ENUM('audio','image','metadata','video','video_image','video_chapter_image','trailer','caption','subtitles','forced_subtitles','trigger');;
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
