CREATE TABLE pp_coupon ( id INT NOT NULL AUTO_INCREMENT , name VARCHAR(255) NOT NULL , PRIMARY KEY (id)) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_polish_ci;
RENAME TABLE pp_coupon TO pp_shop_coupon;
ALTER TABLE pp_shop_coupon ADD status INT NOT NULL DEFAULT '0' AFTER name;
ALTER TABLE pp_shop_coupon ADD type INT NOT NULL DEFAULT '1' AFTER status;
ALTER TABLE pp_shop_coupon ADD amount DECIMAL(12,2) NULL DEFAULT NULL AFTER type;
ALTER TABLE pp_shop_coupon ADD one_time INT NOT NULL DEFAULT '1' AFTER amount;
ALTER TABLE pp_shop_coupon ADD used INT NOT NULL DEFAULT '0' AFTER one_time;
ALTER TABLE pp_shop_orders ADD coupon_id INT NULL DEFAULT NULL AFTER summary;
ALTER TABLE pp_shop_orders ADD FOREIGN KEY (coupon_id) REFERENCES pp_shop_coupon(id) ON DELETE SET NULL ON UPDATE SET NULL;
ALTER TABLE pp_shop_orders ADD coupon_amount DECIMAL(12,2) NULL DEFAULT NULL AFTER coupon_id;
ALTER TABLE pp_shop_orders ADD coupon_summary DECIMAL(12,2) NULL DEFAULT NULL AFTER coupon_amount;
ALTER TABLE pp_shop_coupon ADD date_used TIMESTAMP NULL DEFAULT NULL AFTER used;
ALTER TABLE pp_shop_orders ADD coupon_type INT NULL DEFAULT NULL AFTER coupon_id;