<?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="urvigala">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            USE compilations;;

            DROP TABLE IF EXISTS `catalog_library`;;

            CREATE TABLE `catalog_library` (
              `tuid` INT(11) UNSIGNED NOT NULL COMMENT 'Track unique id from track table.',
              `release_name` VARCHAR(255) DEFAULT NULL COMMENT 'Release name.',
              `track_name` VARCHAR(255) DEFAULT NULL COMMENT 'Name/Title of the track.',
              `isrc` VARCHAR(16) DEFAULT NULL COMMENT 'ISRC code of the track.',
              `manufacturer_upc` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'UPC of releases table.',
              `display_artist` TEXT COMMENT 'Name of the artist of artist_info table.',
              `track_composers` TEXT COMMENT 'Name of track artist of type composer.',
              `track_performers` TEXT COMMENT 'Name of track artist of type performer.',
              `track_orchestras` TEXT COMMENT 'Name of track artist of type orchestra.',
              `track_conductors` TEXT COMMENT 'Name of track artist of type conductor.',
              `track_ensembles` TEXT COMMENT 'Name of track artist of type ensemble.',
              `cd` TINYINT(3) UNSIGNED DEFAULT NULL COMMENT 'CD volume number of the track.',
              `track_id` SMALLINT(5) UNSIGNED DEFAULT NULL COMMENT 'Track number of the track.',
              `genre` VARCHAR(15) NOT NULL COMMENT 'Genre name.',
              `sub_genere` VARCHAR(80) NOT NULL COMMENT 'Subgenre name.',
              `label_name` VARCHAR(100) DEFAULT NULL COMMENT 'Company/Name of the label from vendor table.',
              `length_minute` SMALLINT(5) UNSIGNED DEFAULT NULL COMMENT 'Track Length (Minutes).',
              `length_seconds` SMALLINT(5) UNSIGNED DEFAULT NULL COMMENT 'Track Length (Seconds).',
              `orchard_upc` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Orchard (Cross-Label) UPC.',
              `label_splits` float DEFAULT NULL COMMENT 'Orchard Compilation Split(Label Share).',
              `label_id` INT(10) UNSIGNED NOT NULL COMMENT 'Original Label ID',
              `p_line` VARCHAR(255) DEFAULT NULL COMMENT 'Phonogram right info of the track.',
              `deletions` ENUM('Y','N') NOT NULL DEFAULT 'N' COMMENT 'Yes OR No indicates whether the release is deleted.',
              `songwriter` TEXT COMMENT 'Name of the songwriter.',
              `publisher` TEXT COMMENT 'Name of the publisher.',
              UNIQUE KEY (`tuid`)
            ) ENGINE=INNODB DEFAULT CHARSET=utf8;;

        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

                USE compilations;;

                DROP TABLE IF EXISTS `catalog_library`;;

            </sql>
        </rollback>
    </changeSet>
    <changeSet id="2" author="urvigala">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            USE compilations;;

            DROP TABLE IF EXISTS `territory_carveout`;;

            CREATE TABLE `territory_carveout` (
              `label_id` int(10) unsigned DEFAULT NULL COMMENT 'Orchard label id',
              `upc` bigint(20) unsigned NOT NULL,
              `territory_carveouts` text,
              PRIMARY KEY (`upc`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1;;
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

                USE compilations;;

                DROP TABLE IF EXISTS `territory_carveout`;;

            </sql>
        </rollback>
    </changeSet>
    <changeSet id="3" author="urvigala">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            USE compilations;;

            DROP TABLE IF EXISTS `dms_carveout`;;

            CREATE TABLE `dms_carveout` (
              `label_id` int(10) unsigned DEFAULT NULL COMMENT 'Orchard label id',
              `upc` bigint(20) unsigned NOT NULL,
              `dms_carveouts` text,
              PRIMARY KEY (`upc`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1;;


        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">

                USE compilations;;

                DROP TABLE IF EXISTS `dms_carveout`;;

            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
