-- Deploy gaia:channel_2015_12_31_init_channel to mysql

BEGIN;
CREATE TABLE `channel_channel` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(100) NOT NULL,
    `url_name` varchar(100) NOT NULL,
    `pack` bool NOT NULL
    );
CREATE TABLE `channel_version` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `version` varchar(20) NOT NULL,
    `release_time` datetime(6) NOT NULL,
    `md5` varchar(30) NOT NULL,
    `description` longtext NOT NULL,
    `is_released` bool NOT NULL
    );
CREATE TABLE `channel_versiontochannel` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `packed_time` datetime(6) NOT NULL,
    `release_time` datetime(6) NOT NULL,
    `is_released` bool NOT NULL,
    `channel_id` integer NOT NULL,
    `version_id` integer NOT NULL
    );
ALTER TABLE `channel_versiontochannel`
    ADD CONSTRAINT `channel_versio_channel_id_2da2916d7643d628_fk_channel_channel_id`
    FOREIGN KEY (`channel_id`)
    REFERENCES `channel_channel` (`id`);
ALTER TABLE `channel_versiontochannel`
    ADD CONSTRAINT `channel_versio_version_id_18af8a4e7051ef71_fk_channel_version_id`
    FOREIGN KEY (`version_id`)
    REFERENCES `channel_version` (`id`);

COMMIT;