-- Garment-specific Addons — run AFTER etailorz_addons.sql

CREATE TABLE IF NOT EXISTS `addon_garment_type` (
  `addon_id` BIGINT UNSIGNED NOT NULL,
  `garment_type_id` BIGINT UNSIGNED NOT NULL,
  PRIMARY KEY (`addon_id`, `garment_type_id`),
  CONSTRAINT `agt_addon_id_foreign` FOREIGN KEY (`addon_id`) REFERENCES `addons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `agt_garment_type_id_foreign` FOREIGN KEY (`garment_type_id`) REFERENCES `garment_types` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Example: link the 4 sample addons to Blouse and Shirt (edit IDs to match your data)
-- Run this manually after checking your actual garment_types.id and addons.id values:
--
-- INSERT INTO addon_garment_type (addon_id, garment_type_id)
-- SELECT a.id, g.id FROM addons a, garment_types g
-- WHERE a.name = 'Embroidery' AND g.code IN ('blouse', 'chudithar');
