CREATE TABLE `vn`.`osrmConfig` (
	`id` int(10) unsigned NOT NULL,
	`url` varchar(100) NOT NULL COMMENT 'Dirección base de la API',
	`tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas',
	PRIMARY KEY (`id`),
	CONSTRAINT `osrmConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

-- Para que no de error al añadir la FK de zone
UPDATE vn.zone
	SET price = 0.1
	WHERE price = 0;

ALTER TABLE vn.`zone`
	ADD addressFk int(11) DEFAULT NULL COMMENT 'Punto de distribución de donde salen para repartir',
	ADD CONSTRAINT zone_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE;

ALTER TABLE vn.zoneConfig
	ADD defaultAddressFk int(11) DEFAULT NULL NULL COMMENT 'Punto de distribución por defecto',
	ADD CONSTRAINT zoneConfig_address_FK FOREIGN KEY (defaultAddressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE;
