<?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="rroy">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
		USE art_relations;;
		
		DROP TRIGGER IF EXISTS `before_insert_track`;;
        
		CREATE DEFINER = 'theorchard'@'10.10.%' TRIGGER `before_insert_track` BEFORE INSERT ON `track`
			FOR EACH ROW BEGIN
				CALL art_relations.sp_get_track_offer_type(NEW.length_minute, NEW.length_seconds, NEW.offer_type, @return_offer_type);
				SET NEW.offer_type = @return_offer_type;
			END;;
        </sql>
        <rollback>           
            DROP PROCEDURE IF EXISTS `art_relations`.`before_insert_track`;;
        </rollback>
    </changeSet>
</databaseChangeLog>
