-- dependson: api_0001_add_table_campaign.sql
-- model: api.models.Coupon, api.models.CouponInfo
-- description:
--  alter table api_coupon, add column campaign, is_recommond, recommend_ordering
--  alter table api_couponinfo, add column channel

-- author: Pengfei.X
-- date: 2015.08.31 14:46:00

BEGIN;

ALTER TABLE api_coupon ADD COLUMN `campaign_id` int(11) DEFAULT NULL;
ALTER TABLE api_coupon ADD COLUMN `is_recommand` tinyint(1) NOT NULL;
ALTER TABLE api_coupon ADD COLUMN `recommand_ordering` int(11) NOT NULL;

ALTER TABLE api_coupon ADD CONSTRAINT `fk_coupon_campaign_id` FOREIGN KEY (`campaign_id`) REFERENCES `api_campaign` (`id`);

ALTER TABLE api_couponinfo ADD COLUMN `channel` int(11) DEFAULT NULL;
ALTER TABLE api_couponinfo MODIFY COLUMN `coupon_launch_id` int(11) DEFAULT NULL;

COMMIT;
