-- Deploy gaia:2017_12_05_create_api_rankboardbatch to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `api_rankboardbatch_tags` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `rankboardbatch_id` integer NOT NULL,
    `tag_id` integer NOT NULL,
    UNIQUE (`rankboardbatch_id`, `tag_id`)
)
;
ALTER TABLE `api_rankboardbatch_tags` ADD CONSTRAINT `tag_id_refs_id_dc704b5a` FOREIGN KEY (`tag_id`) REFERENCES `api_tag` (`id`);
CREATE TABLE `api_rankboardbatch` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(30) NOT NULL,
    `type` varchar(8) NOT NULL,
    `image` varchar(300) NOT NULL,
    `describe` varchar(200) NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `is_online` bool NOT NULL,
    `share_title` varchar(100) NOT NULL,
    `share_content` varchar(300) NOT NULL,
    `share_image` varchar(300) NOT NULL
)
;
ALTER TABLE `api_rankboardbatch_tags` ADD CONSTRAINT `rankboardbatch_id_refs_id_4ebc634c` FOREIGN KEY (`rankboardbatch_id`) REFERENCES `api_rankboardbatch` (`id`);
CREATE TABLE `api_rankboardmap` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `batch_rankboard_id` integer NOT NULL,
    `manual_rankboard_id` integer NOT NULL,
    `city_id` varchar(40) NOT NULL,
    `is_effect` bool NOT NULL,
    `create_time` datetime(6) NOT NULL
)
;
ALTER TABLE `api_rankboardmap` ADD CONSTRAINT `city_id_refs_id_b9e21538` FOREIGN KEY (`city_id`) REFERENCES `api_city` (`id`);
ALTER TABLE `api_rankboardmap` ADD CONSTRAINT `manual_rankboard_id_refs_id_ad4df8ce` FOREIGN KEY (`manual_rankboard_id`) REFERENCES `api_rankboard` (`id`);
ALTER TABLE `api_rankboardmap` ADD CONSTRAINT `batch_rankboard_id_refs_id_fd7d24d6` FOREIGN KEY (`batch_rankboard_id`) REFERENCES `api_rankboardbatch` (`id`);

COMMIT;
