
CREATE TABLE IF NOT EXISTS `ma_VendorBlacklist` (
`id` int(10) unsigned NOT NULL,
  `vendorId` int(10) unsigned NOT NULL,
  `adminId` int(11) NOT NULL,
  `status` enum('blacklist','whitelist') NOT NULL DEFAULT 'blacklist',
  `comment` text NOT NULL,
  `added` datetime NOT NULL,
  `changed` datetime NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


ALTER TABLE `ma_VendorBlacklist`
 ADD PRIMARY KEY (`id`), ADD KEY `vendorId` (`vendorId`), ADD KEY `adminId` (`adminId`);

ALTER TABLE `ma_VendorBlacklist`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;

ALTER TABLE `ma_VendorBlacklist`
ADD CONSTRAINT `ma_VendorBlacklist_ibfk_1` FOREIGN KEY (`adminId`) REFERENCES `ma_Admin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `ma_VendorBlacklist_ibfk_2` FOREIGN KEY (`vendorId`) REFERENCES `ma_Vendor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;


CREATE TABLE IF NOT EXISTS `ma_VendorTribeBlacklist` (
  `vendorId` int(11) unsigned NOT NULL,
  `tribeId` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `ma_VendorTribeBlacklist`
 ADD PRIMARY KEY (`vendorId`,`tribeId`), ADD KEY `vendorId` (`vendorId`), ADD KEY `tribeId` (`tribeId`);


ALTER TABLE `ma_VendorTribeBlacklist`
ADD CONSTRAINT `ma_VendorTribeBlacklist_ibfk_2` FOREIGN KEY (`tribeId`) REFERENCES `ma_Tribe` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `ma_VendorTribeBlacklist_ibfk_1` FOREIGN KEY (`vendorId`) REFERENCES `ma_Vendor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;


ALTER TABLE `ma_Vendor` ADD `blacklistedByAdmin` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `taxationPeriod`;

INSERT INTO `ma_DAdminAclResource` (`id`, `title`, `sorter`) VALUES (13, 'Vendor Rates (view)', '25');
INSERT INTO `ma_DAdminAclResource` (`id`, `title`, `sorter`) VALUES (14, 'Vendor Rates (rate)', '27');
INSERT INTO `ma_DAdminAclResource` (`id`, `title`, `sorter`) VALUES (15, 'Vendor Rates (blacklist)', '29');

INSERT INTO `ma_DTribalAccountAclResource` (`id`, `title`, `sorter`) VALUES (10, 'Vendor Rates (view)', '15');
INSERT INTO `ma_DTribalAccountAclResource` (`id`, `title`, `sorter`) VALUES (11, 'Vendor Rates (rate)', '17');
INSERT INTO `ma_DTribalAccountAclResource` (`id`, `title`, `sorter`) VALUES (12, 'Vendor Rates (blacklist)', '19');


