<?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="101" author="jian">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
        <![CDATA[
            USE direct_delivery;;

            DROP PROCEDURE IF EXISTS sp_set_asset_location_status_to_encoding;;

            CREATE DEFINER=theorchard_dd@127.0.0.1 PROCEDURE sp_set_asset_location_status_to_encoding(IN assetLocID INT, IN errLog TEXT)
            BEGIN
                UPDATE asset_location SET status = 'encoding', error_log = errLog, last_modified = NOW()
                WHERE asset_location_id = assetLocID 
                    AND status <> 'encoding';
            END;;
        ]]>
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            <![CDATA[
                USE direct_delivery;;

                DROP PROCEDURE IF EXISTS sp_set_asset_location_status_to_encoding;;
            ]]>
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
