-- BEGIN CHANGE: Pacotes promocionais configuraveis (bundle = set/arma/etc)
-- Oferta pai continua em z_shop_offer / z_shopguild_offer com offer_type='bundle'.
-- catalog: 'donate' | 'guild' (offer_id aponta para a tabela correspondente).

CREATE TABLE IF NOT EXISTS `z_shop_bundle_group` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `catalog` VARCHAR(16) NOT NULL DEFAULT 'donate',
  `offer_id` INT NOT NULL,
  `label` VARCHAR(64) NOT NULL DEFAULT '',
  `sort_order` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  `min_select` TINYINT UNSIGNED NOT NULL DEFAULT 1,
  `max_select` TINYINT UNSIGNED NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  KEY `idx_catalog_offer` (`catalog`, `offer_id`),
  KEY `idx_offer_sort` (`offer_id`, `sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `z_shop_bundle_option` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_id` INT UNSIGNED NOT NULL,
  `label` VARCHAR(64) NOT NULL DEFAULT '',
  `sort_order` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `idx_group_sort` (`group_id`, `sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `z_shop_bundle_option_item` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `option_id` INT UNSIGNED NOT NULL,
  `itemid` INT NOT NULL DEFAULT 0,
  `count` INT NOT NULL DEFAULT 1,
  `sort_order` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `idx_option_sort` (`option_id`, `sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- END CHANGE
