-- Deploy gaia:2019_06_04_add_beautyphoto_table to mysql

BEGIN;

CREATE TABLE `api_motherword` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(128) NOT NULL,
    `gender` smallint NOT NULL,
    `content_ad` longtext NOT NULL,
    `is_online` bool NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `updated_time` datetime(6) NOT NULL
)
;
CREATE TABLE `api_beautyphoto` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `role_name` varchar(128) NOT NULL,
    `url` varchar(300) NOT NULL,
    `gender` smallint NOT NULL,
    `is_online` bool NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `updated_time` datetime(6) NOT NULL
)
;
CREATE TABLE `api_motherwordphotorelated` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `beautyphoto_id` integer NOT NULL,
    `motherword_id` integer NOT NULL
)
;
ALTER TABLE `api_motherwordphotorelated` ADD CONSTRAINT `beautyphoto_id_refs_id_6fd106d5` FOREIGN KEY (`beautyphoto_id`) REFERENCES `api_beautyphoto` (`id`);
ALTER TABLE `api_motherwordphotorelated` ADD CONSTRAINT `motherword_id_refs_id_c454efd4` FOREIGN KEY (`motherword_id`) REFERENCES `api_motherword` (`id`);
CREATE INDEX `api_motherwordphotorelated_5788e305` ON `api_motherwordphotorelated` (`beautyphoto_id`);
CREATE INDEX `api_motherwordphotorelated_5af93bdd` ON `api_motherwordphotorelated` (`motherword_id`);



COMMIT;
