-- Deploy gaia:api_2016_08_18_alter_table_api_diary_add_table_api_diaryoperate to mysql

BEGIN;

ALTER TABLE `api_diary`
ADD COLUMN `audit_status` varchar(1) NOT NULL DEFAULT 0,
ADD COLUMN `audit_time` datetime,
ADD COLUMN `content_level` varchar(1) NOT NULL DEFAULT 0;

CREATE TABLE `api_diaryoperate` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `diary_id` INTEGER,
    `operate_time` datetime NOT NULL,
    `operation` varchar(1) NOT NULL,
    `topic` varchar(30)
);
ALTER TABLE `api_diaryoperate` ADD CONSTRAINT `diary_id_refs_id` FOREIGN KEY (`diary_id`) REFERENCES `api_diary` (`id`);
CREATE INDEX `api_diaryoperate_diary` ON `api_diaryoperate` (`diary_id`);

COMMIT;
