<?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="nlevkovich">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            DROP TABLE IF EXISTS `ROLLBACK-PHYS37-releases`;;
            CREATE TABLE `ROLLBACK-PHYS37-releases`
            SELECT `release_id`, `distribution_format_id` FROM releases WHERE `product_type_id` = 1;;

            UPDATE `releases` as r
            INNER JOIN `ROLLBACK-PHYS37-releases` as rb on r.`release_id` = rb.`release_id`
            SET r.`distribution_format_id` = 1;;
        </sql>
        <rollback>
            UPDATE `releases` as r
            INNER JOIN `ROLLBACK-PHYS37-releases` as rb on r.`release_id` = rb.`release_id`
            SET r.`distribution_format_id` = rb.`distribution_format_id`;;
            DROP TABLE `ROLLBACK-PHYS37-releases`;;
        </rollback>
    </changeSet>
</databaseChangeLog>
