-- Deploy gaia:api_2017_02_06_create_seokeyword to mysql

BEGIN;

CREATE TABLE `api_seocategory` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `tag_id` integer NOT NULL,
    `name` varchar(64) NOT NULL,
    `wiki_id` integer DEFAULT NULL,
    `category_type` varchar(4) DEFAULT NULL,
    `icon` varchar(128) DEFAULT NULL,
    `banner` varchar(128) DEFAULT NULL,
    `show_diary` bool NOT NULL,
    `desc_md` longtext DEFAULT NULL
);

CREATE TABLE `api_categoryrelation` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `parent_category_id` integer DEFAULT NULL,
    `child_category_id` integer DEFAULT NULL
);
ALTER TABLE `api_categoryrelation` ADD CONSTRAINT `parent_category_id_refs_id_5b2cf103` FOREIGN KEY (`parent_category_id`) REFERENCES `api_seocategory` (`id`);
ALTER TABLE `api_categoryrelation` ADD CONSTRAINT `child_category_id_refs_id_5b2cf103` FOREIGN KEY (`child_category_id`) REFERENCES `api_seocategory` (`id`);
CREATE INDEX `api_categoryrelation_5639c68d` ON `api_categoryrelation` (`parent_category_id`);
CREATE INDEX `api_categoryrelation_08f06e87` ON `api_categoryrelation` (`child_category_id`);

COMMIT;
