<?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="mdadhania">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <![CDATA[
                USE art_relations;;
                DROP TRIGGER IF EXISTS after_delete_customer_master_master;;

                CREATE DEFINER = 'theorchard'@'10.10.%' TRIGGER after_delete_customer_master_master AFTER DELETE ON customer_master_master
                FOR EACH ROW 
                BEGIN
                    INSERT INTO `art_relations_log`.`customer_master_master_log` SET
                    `log_timestamp` = NOW(),
                    `log_action` = 'delete',
                    `customer_master_master_id` = OLD.`customer_master_master_id`,
                    `customer_name` = OLD.`customer_name`,
                    `sony_dms_code`= OLD.`sony_dms_code`,
                    `ci_dms_code` = OLD.`ci_dms_code`,
                    `delivery_option` = OLD.`delivery_option`,
                    `show_delivery_info` = OLD.`show_delivery_info`,
                    `product_type_id` = OLD.`product_type_id`,
                    `delivery_cap` = OLD.`delivery_cap`,
                    `weekly_limit` = OLD.`weekly_limit`,
                    `eo_limit` = OLD.`eo_limit`,
                    `encoding_order_status` = OLD.`encoding_order_status`,
                    `mv_delivery_option` = OLD.`mv_delivery_option`,
                    `ddex_party_id` = OLD.`ddex_party_id`,
                    `optin_date` = OLD.`optin_date`,
                    `required_genre_code` = OLD.`required_genre_code`,
                    `required_subgenre_code` = OLD.`required_subgenre_code`,
                    `required_subgenre` = OLD.`required_subgenre`,
                    `instant_grat` = OLD.`instant_grat`,
                    `hd_only` = OLD.`hd_only`,
                    `status` = OLD.`status`,
                    `label_store` = OLD.`label_store`,
                    `supports_timed_release` = OLD.`supports_timed_release`,
                    `supports_timed_release_updated_by` = OLD.`supports_timed_release_updated_by`,
                    `supports_timed_release_last_updated` = OLD.`supports_timed_release_last_updated`,
                    `supports_localization` = OLD.`supports_localization`,
                    `supports_localization_updated_by` = OLD.`supports_localization_updated_by`,
                    `supports_localization_updated_by_date_time` = OLD.`supports_localization_updated_by_date_time`,
                    `is_user_defined_contributors_supported` = OLD.`is_user_defined_contributors_supported`,
                    `is_user_defined_contributors_supported_updated_by` = OLD.`is_user_defined_contributors_supported_updated_by`,
                    `is_user_defined_contributors_supported_last_updated` = OLD.`is_user_defined_contributors_supported_last_updated`,
                    `exclusive_audio_content` = OLD.`exclusive_audio_content`,
                    `updated_by` = OLD.`updated_by`,
                    `updated_on` = OLD.`updated_on`;
                END;;
            ]]>
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
                <![CDATA[
                    USE art_relations;;
                    DROP TRIGGER IF EXISTS after_delete_customer_master_master;;
                ]]>
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
