<?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="mdadhania">
        <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
            CREATE TABLE track_crop_info (
                track_id INT(10) UNSIGNED NOT NULL,
                crop_left INT(10),
                crop_right INT(10),
                crop_top INT(10),
                crop_bottom INT(10),
                orchard_user_id INT(10) UNSIGNED DEFAULT NULL,
                created_timestamp TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
                updated_timestamp TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                PRIMARY KEY (`track_id`),
                CONSTRAINT `FK_track_crop_info_track_id` FOREIGN KEY (`track_id`) REFERENCES `track` (`id`) ON DELETE CASCADE,
                CONSTRAINT `FK_track_crop_info_orchard_user_id` FOREIGN KEY (`orchard_user_id`) REFERENCES `orchadmin_users` (`id`) ON DELETE SET NULL
            );;
        </sql>
        <rollback>
            <sql dbms="mysql" endDelimiter=";;" splitStatements="true" stripComments="true">
                DROP TABLE track_crop_info;;
            </sql>
        </rollback>
    </changeSet>
</databaseChangeLog>
