-- Deploy gaia:api_2015_11_30_creat_table_api_greetingpopup to mysql

BEGIN;

CREATE TABLE `api_greetingpopup` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `title` varchar(100) NOT NULL,
    `image` varchar(256) NOT NULL,
    `type` varchar(2) NOT NULL,
    `url` varchar(256) DEFAULT NULL,
    `start_time` datetime,
    `end_time` datetime,
    `is_online` bool DEFAULT FALSE,
    `topic_id` int(11) DEFAULT NULL,
    `diary_id` int(11) DEFAULT NULL,
    `special_id` int(11) DEFAULT NULL,
    `service_id` int(11) DEFAULT NULL,
    `tag_id` int(11) DEFAULT NULL,
    `activity_id` int(11) DEFAULT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE `api_greetingpopup` ADD CONSTRAINT
        `api_greetingpopup_topic_id_ref_api_problem`
        FOREIGN KEY (`topic_id`) REFERENCES `api_problem` (`id`);
ALTER TABLE `api_greetingpopup` ADD CONSTRAINT
        `api_greetingpopup_diary_id_ref_api_diary`
    FOREIGN KEY (`diary_id`) REFERENCES `api_diary` (`id`);
ALTER TABLE `api_greetingpopup` ADD CONSTRAINT
        `api_greetingpopup_special_id_ref_api_special`
    FOREIGN KEY (`special_id`) REFERENCES `api_special` (`id`);
ALTER TABLE `api_greetingpopup` ADD CONSTRAINT
        `api_greetingpopup_service_id_ref_api_service`
    FOREIGN KEY (`service_id`) REFERENCES `api_service` (`id`);
ALTER TABLE `api_greetingpopup` ADD CONSTRAINT
        `api_greetingpopup_tag_id_ref_api_tag`
    FOREIGN KEY (`tag_id`) REFERENCES `api_tag` (`id`);
ALTER TABLE `api_greetingpopup` ADD CONSTRAINT
        `api_greetingpopup_activity_id_ref_api_activity`
    FOREIGN KEY (`activity_id`) REFERENCES `api_activity` (`id`);
-- XXX Add DDLs here.

COMMIT;
