-- Deploy mimas-talos:api_2018_01_05_alter_diary to mysql

BEGIN;

CREATE TABLE `api_diary_extra` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `diary_id` integer NOT NULL UNIQUE,
    `topic_count` integer DEFAULT 0 NOT NULL,
    `reply_count` integer DEFAULT 0 NOT NULL,
    `vote_count` integer DEFAULT 0 NOT NULL,
    `total_pv` integer DEFAULT 0 NOT NULL
);
ALTER TABLE `api_diary_extra` ADD CONSTRAINT `diary_id_refs_id_411136gp` FOREIGN KEY (`diary_id`) REFERENCES `api_diary` (`id`);


COMMIT;
