-- Deploy gaia:api_20161117_update_api_zone to mysql

BEGIN;

ALTER TABLE `api_zone`
ADD COLUMN `show_diary_tab` bool NOT NULL DEFAULT 1,
ADD COLUMN `show_topic_tab` bool NOT NULL DEFAULT 1,
ADD COLUMN `show_service_tab` bool NOT NULL DEFAULT 0,
ADD COLUMN `default_sort_type` integer NOT NULL DEFAULT 0,
ADD COLUMN `topic_tab_position` integer NOT NULL DEFAULT 1,
ADD COLUMN `diary_tab_position` integer NOT NULL DEFAULT 2,
ADD COLUMN `service_tab_position` integer NOT NULL DEFAULT 999999,
ADD COLUMN `zone_type` integer NOT NULL DEFAULT 0;

CREATE TABLE `api_overheaddiary` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `zone_id` integer NOT NULL,
    `diary_id` integer NOT NULL,
    `rank` integer NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `deleted` bool NOT NULL DEFAULT 0
)
;

ALTER TABLE `api_overheadtopic` ADD COLUMN `deleted` bool NOT NULL DEFAULT 0;


COMMIT;
