-- Deploy mimas-talos:2019-06-04-subscript-article to mysql

BEGIN;

-- Create model Category
CREATE TABLE `api_sub_category` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(100) NOT NULL,
    `icon` varchar(100) NOT NULL,
    `is_online` bool NOT NULL,
    `ordering` integer NOT NULL,
    `is_header_article` bool NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL
);

-- Create model SubscripArticle
CREATE TABLE `api_sub_article` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(200) NOT NULL,
    `title` varchar(200) NOT NULL,
    `url` varchar(200) NOT NULL,
    `image_url` varchar(300) NOT NULL,
    `share_img` varchar(200) NOT NULL,
    `share_content` varchar(200) NOT NULL,
    `is_online` bool NOT NULL,
    `is_header_article` bool NOT NULL,
    `platform` integer,
    `ordering` integer NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL
);

-- Create model SubscripArticleCategory
CREATE TABLE `api_sub_article_category` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `is_online` bool NOT NULL,
    `article_id` integer NOT NULL,
    `category_id` integer NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL
);

-- Create model SubscripArticleTag
CREATE TABLE `api_sub_article_tag` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `is_online` bool NOT NULL,
    `article_id` integer NOT NULL,
    `tag_id` integer NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL
);

COMMIT;
