-- Deploy gaia:api_2016_09_14_add_table_wechatmaterial to mysql

BEGIN;

CREATE TABLE `api_wechatmaterial` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `material_id` varchar(128) NOT NULL,
    `number` integer NOT NULL,
    `thumb_media_id` varchar(128) NOT NULL,
    `thumb_url` varchar(256) NOT NULL,
    `show_cover_pic` bool NOT NULL,
    `author` varchar(128) NOT NULL,
    `digest` varchar(128) NOT NULL,
    `content` longtext NOT NULL,
    `url` varchar(256) NOT NULL,
    `content_source_url` varchar(256) NOT NULL,
    `update_time` datetime(6) NOT NULL,
    `name` varchar(128) NOT NULL,
    `title` varchar(256) NOT NULL,
    `topic_id` integer,
    UNIQUE (`material_id`, `number`)
)
;
ALTER TABLE `api_wechatmaterial` ADD CONSTRAINT `topic_id_refs_id_b2c64f70` FOREIGN KEY (`topic_id`) REFERENCES `api_problem` (`id`);
CREATE INDEX `api_wechatmaterial_76f18ad3` ON `api_wechatmaterial` (`topic_id`);
COMMIT;
