-- Deploy gaia:2017_11_14_add_pushcoupon to mysql

BEGIN;

CREATE TABLE `api_pushcoupon` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(64) NOT NULL,
    `eta` datetime(6) NOT NULL,
    `gift_id` integer NOT NULL,
    `push_popup` bool NOT NULL,
    `popup_img` varchar(256) NOT NULL,
    `push_alert` bool NOT NULL,
    `alert_msg` varchar(64) NOT NULL,
    `status` integer NOT NULL,
    `create_user_id` integer NOT NULL,
    `updated_time` datetime(6) NOT NULL,
    `created_time` datetime(6) NOT NULL
)
;
ALTER TABLE `api_pushcoupon` ADD CONSTRAINT `gift_id_refs_id_62484040` FOREIGN KEY (`gift_id`) REFERENCES `api_channelgift` (`id`);
ALTER TABLE `api_pushcoupon` ADD CONSTRAINT `create_user_id_refs_id_12965f4a` FOREIGN KEY (`create_user_id`) REFERENCES `auth_user` (`id`);
CREATE TABLE `api_pushcouponuser` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `push_coupon_id` integer NOT NULL,
    `user_id` integer NOT NULL,
    `get_coupon_time` datetime(6),
    `push_coupon_status` integer NOT NULL,
    `has_show_popup` bool NOT NULL
)
;
ALTER TABLE `api_pushcouponuser` ADD CONSTRAINT `user_id_refs_id_b06ed506` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
ALTER TABLE `api_pushcouponuser` ADD CONSTRAINT `push_coupon_id_refs_id_f203507a` FOREIGN KEY (`push_coupon_id`) REFERENCES `api_pushcoupon` (`id`);

COMMIT;
