-- Deploy gaia:wiki_add_table_video_library to mysql

BEGIN;

CREATE TABLE `api_video_library` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `source_id` integer NOT NULL,
    `raw_image_url` varchar(128) NOT NULL,
    `water_image_url` varchar(128) NOT NULL,
    `raw_video_url` varchar(128) NOT NULL,
    `water_video_url` varchar(128) NOT NULL,
    `persistent_id` varchar(128) NOT NULL,
    `persistent_status` integer NOT NULL,
    `video_type` integer NOT NULL,
    `ordering` integer NOT NULL,
    `is_online` bool NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL
);


CREATE TABLE `api_video_relation_word` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `video_id` integer NOT NULL,
    `word_id` integer NOT NULL
);

ALTER TABLE `api_video_relation_word` ADD CONSTRAINT `video_id_refs_id_a211ddb2` FOREIGN KEY (`video_id`) REFERENCES `api_video_library` (`id`);
ALTER TABLE `api_video_relation_word` ADD CONSTRAINT `word_id_refs_id_b1f9b2cc` FOREIGN KEY (`word_id`) REFERENCES `api_wordrel` (`id`);

CREATE INDEX `api_video_library_1e78ee02` ON `api_video_library` (`source_id`);
CREATE INDEX `api_video_relation_word_c11471f1` ON `api_video_relation_word` (`video_id`);
CREATE INDEX `api_video_relation_word_558fda87` ON `api_video_relation_word` (`word_id`);

COMMIT;
