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

                CREATE DEFINER = 'theorchard'@'10.10.%' TRIGGER after_update_vend_contact AFTER UPDATE ON vend_contact
                FOR EACH ROW 
                BEGIN
                    IF (NEW.login != OLD.login AND NEW.master = 'Y')
                    THEN
                        CALL cloudsearch.sp_upsert_vendor(NEW.vendor_id);
                    END IF;
                END;;
            ]]>
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
                <![CDATA[
                    USE art_relations;;
                    DROP TRIGGER IF EXISTS after_update_vend_contact;;
                ]]>
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
