UPDATE `ma_Settings` SET `sorter` = '13' WHERE `ma_Settings`.`name` = 'contactFormEmailThanksMessage'; 
INSERT INTO `ma_Settings` (`name`, `idCategory`, `fieldType`, `label`, `value`, `options`, `description`, `required`, `system`, `sorter`, `added`, `changed`) VALUES
	('googleMapApiKey', 1, 'text', 'Google Maps API Key', '', '', '', 'n', 'n', 10, '0000-00-00 00:00:00', '0000-00-00 00:00:00');

-- --------------------------------------------------------
-- --------------------------------------------------------

ALTER TABLE `ma_Tribe` 
	ADD `address` VARCHAR(255) NOT NULL AFTER `logo`,
	ADD `city` VARCHAR(255) NOT NULL AFTER `address`,
	ADD `state` CHAR(2) NOT NULL AFTER `city`,
	ADD `zip` VARCHAR(16) NOT NULL AFTER `state`; 
	
ALTER TABLE `ma_Tribe`
	ADD `latitude` DECIMAL(12,7) DEFAULT NULL AFTER `zip`,
	ADD `longitude` DECIMAL(12,7) DEFAULT NULL AFTER `latitude`,
	ADD `formattedAddress` VARCHAR(255) DEFAULT NULL AFTER `longitude`; 
 
ALTER TABLE `ma_Vendor`
	ADD `latitude` DECIMAL(12,7) DEFAULT NULL AFTER `vendorServices`,
	ADD `longitude` DECIMAL(12,7) DEFAULT NULL AFTER `latitude`,
	ADD `formattedAddress` VARCHAR(255) DEFAULT NULL AFTER `longitude`; 

-- --------------------------------------------------------
-- -------------------------------------------------------- 

CREATE TABLE `ma_VendorDistance` (
  `tribeId` int(10) UNSIGNED NOT NULL,
  `vendorId` int(10) UNSIGNED NOT NULL,
  `distance` float(10,3) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 ALTER TABLE `ma_VendorDistance`
  ADD PRIMARY KEY (`tribeId`,`vendorId`),
  ADD KEY `tribeId` (`tribeId`),
  ADD KEY `vendorId` (`vendorId`);
  
ALTER TABLE `ma_VendorDistance`
  ADD CONSTRAINT `ma_VendorDistance_ibfk_1` FOREIGN KEY (`vendorId`) REFERENCES `ma_Vendor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `ma_VendorDistance_ibfk_2` FOREIGN KEY (`tribeId`) REFERENCES `ma_Tribe` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

