ALTER TABLE `#__sr_discounts` ADD COLUMN `scope` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `stop_further_processing`;
ALTER TABLE `#__sr_discounts` CHANGE COLUMN `reservation_asset_id` `reservation_asset_id` INT(11) UNSIGNED NULL;
ALTER TABLE `#__sr_discounts` CHANGE COLUMN `applied_to` `applied_to` TEXT;

ALTER TABLE `#__sr_discounts` ADD `applied_days` VARCHAR(45) NULL AFTER `scope`;
ALTER TABLE `#__sr_discounts` ADD `applied_type` TINYINT(1) NULL AFTER `applied_days`;

CREATE TABLE IF NOT EXISTS `#__sr_discount_experience_xref` (
  `discount_id` INT(11) UNSIGNED NOT NULL,
  `experience_id` INT(11) UNSIGNED NOT NULL,
  PRIMARY KEY (`discount_id`, `experience_id`),
  INDEX `fk_discount_exp_xref_exps1_idx` (`experience_id` ASC),
  CONSTRAINT `fk_discount_exp_xref_discounts1`
    FOREIGN KEY (`discount_id`)
    REFERENCES `#__sr_discounts` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_discount_exp_xref_exps1`
    FOREIGN KEY (`experience_id`)
    REFERENCES `#__sr_experiences` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;
