-- Deploy gaia:2019_10_29_create_table_search_activity to mysql

BEGIN;

CREATE TABLE `api_search_activity` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `title` varchar(128) NOT NULL,
    `image` varchar(128) NOT NULL,
    `jump_url` varchar(128) NOT NULL,
    `sub_title` varchar(128) NOT NULL,
    `keywords` varchar(128) NOT NULL,
    `style` integer NOT NULL,
    `is_online` bool NOT NULL,
    `start_time` datetime(6) NOT NULL,
    `end_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `operator_id` integer NOT NULL,
    `tab` integer NOT NULL DEFAULT 0
    );


CREATE TABLE `api_search_sub_activity` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `title` varchar(128) NOT NULL,
    `image` varchar(128) NOT NULL,
    `jump_url` varchar(128) NOT NULL,
    `activity_id` integer NOT NULL
    );

ALTER TABLE `api_search_activity` ADD CONSTRAINT `api_search_activity_operator_id_1e47e3c6_fk_auth_user_id` FOREIGN KEY (`operator_id`) REFERENCES `auth_user` (`id`);

ALTER TABLE `api_search_sub_activity` ADD CONSTRAINT `api_search_sub_activ_activity_id_745813e2_fk_api_searc` FOREIGN KEY (`activity_id`) REFERENCES `api_search_activity` (`id`);

COMMIT;
