-- Deploy gaia:api_2017_03_30_alter_api_pushtask to mysql

BEGIN;

ALTER TABLE `api_pushtask` ADD COLUMN `push_user_type` integer;

CREATE TABLE `api_pushtaskregion` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `pushtask_id` integer NOT NULL,
    `region_id` integer NOT NULL
);
ALTER TABLE `api_pushtaskregion` ADD CONSTRAINT `pushtask_id_refs_id_fc96ce37` FOREIGN KEY (`pushtask_id`) REFERENCES `api_pushtask` (`id`);
ALTER TABLE `api_pushtaskregion` ADD CONSTRAINT `region_id_refs_id_ce1b66d3` FOREIGN KEY (`region_id`) REFERENCES `api_region` (`id`);

CREATE TABLE `api_pushtaskcity` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `pushtask_id` integer NOT NULL,
    `city_id` varchar(40) NOT NULL
);
ALTER TABLE `api_pushtaskcity` ADD CONSTRAINT `city_id_refs_id_f9ebafe9` FOREIGN KEY (`city_id`) REFERENCES `api_city` (`id`);
ALTER TABLE `api_pushtaskcity` ADD CONSTRAINT `pushtask_id_refs_id_42cf50eb` FOREIGN KEY (`pushtask_id`) REFERENCES `api_pushtask` (`id`);

CREATE TABLE `api_pushtasktag` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `pushtask_id` integer NOT NULL,
    `tag_id` integer NOT NULL
);
ALTER TABLE `api_pushtasktag` ADD CONSTRAINT `pushtask_id_refs_id_c30d614e` FOREIGN KEY (`pushtask_id`) REFERENCES `api_pushtask` (`id`);
ALTER TABLE `api_pushtasktag` ADD CONSTRAINT `tag_id_refs_id_a9d70c4f` FOREIGN KEY (`tag_id`) REFERENCES `api_tag` (`id`);

COMMIT;
