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

                CREATE DEFINER = 'theorchard'@'10.10.%' TRIGGER after_insert_mkt_priority AFTER INSERT ON mkt_priority
                FOR EACH ROW 
                BEGIN
                    INSERT INTO `art_relations_log`.`mkt_priority_log` SET
                    `log_timestamp` = NOW(),
                    `log_action` = 'insert',
                    `id` = NEW.`id`,
                    `upc` = NEW.`upc`,
                    `priority` = NEW.`priority`,
                    `country_id` = NEW.`country_id`,
                    `release_id`  = NEW.`release_id`;
                END;;
            ]]>
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <![CDATA[
                USE art_relations;;
                DROP TRIGGER IF EXISTS `after_insert_mkt_priority`;;
            ]]>
            </sql>
        </rollback>
    </changeSet>
    <changeSet id="2" author="vpatel">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <![CDATA[
                USE art_relations;;
                DROP TRIGGER IF EXISTS after_delete_track_instant_grat;;

                CREATE DEFINER = 'theorchard'@'10.10.%' TRIGGER after_delete_track_instant_grat AFTER DELETE ON track_instant_grat
                FOR EACH ROW 
                BEGIN
                    INSERT INTO `art_relations_log`.`track_instant_grat_log` SET
                    `log_timestamp` = NOW(),
                    `log_action` = 'delete',
                    `id` = OLD.`id`,
                    `customer_master_master_id` = OLD.`customer_master_master_id`,
                    `unique_track_id` = OLD.`unique_track_id`,
                    `active` = OLD.`active`,
                    `date` = OLD.`date`,
                    `added_by_user_id` = OLD.`added_by_user_id`,
                    `added_by_user_type` = OLD.`added_by_user_type`,
                    `date_created` = OLD.`date_created`;
                END;;
            ]]>
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <![CDATA[
                USE art_relations;;
                DROP TRIGGER IF EXISTS `after_delete_track_instant_grat`;;
            ]]>
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
