CREATE TABLE pp_shop_product_sets (	id INT ZEROFILL NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL DEFAULT '0', status INT NOT NULL DEFAULT 0, PRIMARY KEY (id)) COLLATE='utf8_polish_ci' ENGINE=InnoDB;
ALTER TABLE pp_shop_product_sets CHANGE COLUMN id id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;
ALTER TABLE pp_shop_product_sets CHANGE COLUMN id id INT(10) NOT NULL AUTO_INCREMENT FIRST;
CREATE TABLE pp_shop_product_sets_products ( id INT NOT NULL AUTO_INCREMENT, set_id INT NOT NULL DEFAULT '0', product_id INT NOT NULL DEFAULT '0', PRIMARY KEY (id), INDEX set_id (set_id), INDEX product_id (product_id) ) COLLATE='utf8_polish_ci' ENGINE=InnoDB;
ALTER TABLE pp_shop_product_sets_products	ADD CONSTRAINT FK_pp_shop_product_sets_products_pp_shop_product_sets FOREIGN KEY (set_id) REFERENCES pp_shop_product_sets (id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE pp_shop_product_sets_products	ADD CONSTRAINT FK_pp_shop_product_sets_products_pp_shop_products FOREIGN KEY (product_id) REFERENCES pp_shop_products (id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE pp_shop_products ADD COLUMN set_id INT NULL AFTER additional_message;
ALTER TABLE pp_shop_products ADD INDEX set_id (set_id);
ALTER TABLE pp_shop_products ADD CONSTRAINT FK_pp_shop_products_pp_shop_product_sets FOREIGN KEY (set_id) REFERENCES pp_shop_product_sets (id) ON UPDATE CASCADE ON DELETE CASCADE;
DROP TABLE pp_shop_products_sets;