CREATE TABLE FeeLevyAmountMaster (
  id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
  name VARCHAR(100) NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB CHARACTER SET utf8;
CREATE UNIQUE INDEX fee_levy_amount_name_idx ON FeeLevyAmountMaster(name);
INSERT INTO FeeLevyAmountMaster(id, name) VALUES (1, 'For all amounts'),(2, 'Slabbed');

SET foreign_key_checks = 0;

ALTER TABLE `Fee` 
ADD COLUMN `levy_amount_id` TINYINT UNSIGNED NOT NULL AFTER `rate_type_id`,
ADD COLUMN `min_amount` MEDIUMINT UNSIGNED DEFAULT NULL AFTER `levy_amount_id`,
ADD COLUMN `max_amount` MEDIUMINT UNSIGNED DEFAULT NULL AFTER `min_amount`,
ADD COLUMN `tax_on_fee` DECIMAL(13,10) DEFAULT NULL AFTER `max_amount`,
ADD FOREIGN KEY (`levy_amount_id`) REFERENCES `FeeLevyAmountMaster` (`id` ) ON DELETE NO ACTION ON UPDATE CASCADE;

UPDATE Fee SET levy_amount_id=1;

SET foreign_key_checks = 1;
