CREATE TABLE continent (
	id INT auto_increment NOT NULL,
	name varchar(100) NULL,
	CONSTRAINT continent_pk PRIMARY KEY (id)
)

ALTER TABLE tour ADD code varchar(100) NOT NULL;


ALTER TABLE country ADD id_continent INT DEFAULT 5 NOT NULL;


CREATE TABLE `user_refresh_tokens` (
	`user_refresh_tokenID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`urf_userID` INT(10) UNSIGNED NOT NULL,
	`urf_token` VARCHAR(1000) NOT NULL,
	`urf_ip` VARCHAR(50) NOT NULL,
	`urf_user_agent` VARCHAR(1000) NOT NULL,
	`urf_created` DATETIME NOT NULL COMMENT 'UTC',
	PRIMARY KEY (`user_refresh_tokenID`)
)
COMMENT='For JWT authentication process';



CREATE TABLE IF NOT EXISTS `booking_payment` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `charge_id` varchar(180) NOT NULL DEFAULT '0',
  `livemode` tinyint NOT NULL DEFAULT (0),
  `tour_booking_id` tinyint NOT NULL DEFAULT (0),
  `created_at` varchar(50) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
);


ALTER TABLE tour_availability MODIFY COLUMN `day` int NULL;



CREATE TABLE `tour_optional_extra` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(180) NOT NULL DEFAULT '',
	`name_esp` VARCHAR(180) NOT NULL DEFAULT '',
	`active` TINYINT NOT NULL DEFAULT (1),
	`name_key` VARCHAR(180) NOT NULL DEFAULT '',
	PRIMARY KEY (`id`)
);





CREATE TABLE `tour_guide_type` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(150) NOT NULL DEFAULT '',
	`name_eng` VARCHAR(150) NOT NULL DEFAULT '',
	`active` VARCHAR(150) NOT NULL DEFAULT '',
	PRIMARY KEY (`id`)
);


CREATE TABLE `tour_extra_language` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(150) NOT NULL DEFAULT '',
	`name_eng` VARCHAR(150) NOT NULL DEFAULT '',
	`active` TINYINT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);



CREATE TABLE `tour_extra_duration` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(150) NOT NULL DEFAULT '',
	`name_eng` VARCHAR(150) NOT NULL DEFAULT '',
	`active` TINYINT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);


CREATE TABLE `tour_extra_vehicle` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(150) NOT NULL DEFAULT '',
	`name_eng` VARCHAR(150) NOT NULL DEFAULT '',
	`active` TINYINT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);


CREATE TABLE `tour_extra_vehicle_extra` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(150) NOT NULL DEFAULT '',
	`name_eng` VARCHAR(150) NOT NULL DEFAULT '',
	`active` TINYINT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);



CREATE TABLE `tour_extras` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(150) NOT NULL DEFAULT '',
	`name_eng` VARCHAR(150) NOT NULL DEFAULT '',
	`type` VARCHAR(150) NOT NULL DEFAULT '',
	`active` TINYINT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);




CREATE TABLE  `tour_meeting_points` (
  `id` int NOT NULL,
  `lat` varchar(50) NOT NULL DEFAULT '',
  `lon` varchar(50) NOT NULL DEFAULT '',
  `address` varchar(250) NOT NULL DEFAULT '',
  `id_tour_details` int NOT NULL DEFAULT (0),
  `pickup` varchar(50) NOT NULL DEFAULT 'downtown',
  PRIMARY KEY (`id`)
);


ALTER TABLE `tour_booking_config`
	CHANGE COLUMN `on_request` `on_request` INT NULL DEFAULT '0' AFTER `max_pax`;


CREATE TABLE IF NOT EXISTS `statuspost` (
  `id` INT NOT NULL,
  `name` VARCHAR(45) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;

INSERT INTO `statuspost` (`id`, `name`) VALUES ('0', 'Inactive');
INSERT INTO `statuspost` (`id`, `name`) VALUES ('1', 'Draft');
INSERT INTO `statuspost` (`id`, `name`) VALUES ('2', 'Published');


CREATE TABLE IF NOT EXISTS `destination_guides` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `id_city` INT NOT NULL,
  `title` VARCHAR(45) NULL,
  `id_statuspost` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_destination_guides_city_idx` (`id_city` ASC),
  INDEX `fk_destination_guides_statuspost1_idx` (`id_statuspost` ASC),
  CONSTRAINT `fk_destination_guides_city`
    FOREIGN KEY (`id_city`)
    REFERENCES `city` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_destination_guides_statuspost1`
    FOREIGN KEY (`id_statuspost`)
    REFERENCES `statuspost` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE TABLE `destination_guides_section` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `htmlcontent` text DEFAULT NULL,
  `section` varchar(45) DEFAULT NULL,
  `id_destination_guides` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_destination_guides_section_destination_guides1_idx` (`id_destination_guides`),
  CONSTRAINT `fk_destination_guides_section_destination_guides1` FOREIGN KEY (`id_destination_guides`) REFERENCES `destination_guides` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;


CREATE TABLE IF NOT EXISTS `destination_guides_seo` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `keywords` VARCHAR(250) NULL,
  `description` VARCHAR(150) NULL,
  `canonicalurl` VARCHAR(80) NULL,
  `slug` VARCHAR(100) NULL,
  `id_destination_guides_section` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_destination_guides_seo_destination_guides_section1_idx` (`id_destination_guides_section` ASC),
  CONSTRAINT `fk_destination_guides_seo_destination_guides_section1`
    FOREIGN KEY (`id_destination_guides_section`)
    REFERENCES `destination_guides_section` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);

CREATE TABLE travel_companion (
	ID int PRIMARY KEY auto_increment,
    name varchar(50)
);
INSERT INTO `travel_companion` (`name`) VALUES ('Solo');
INSERT INTO `travel_companion` (`name`) VALUES ('Pareja');
INSERT INTO `travel_companion` (`name`) VALUES ('Familia');
INSERT INTO `travel_companion` (`name`) VALUES ('Amigos');
INSERT INTO `travel_companion` (`name`) VALUES ('Compañeros de trabajo');


	


CREATE TABLE `tour_images` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`image_date` VARCHAR(150) NOT NULL DEFAULT '0',
	`file_name` VARCHAR(150) NOT NULL DEFAULT '0',
	`guid` VARCHAR(150) NOT NULL DEFAULT '0',
	`caption` VARCHAR(350) NOT NULL DEFAULT '',
	`id_tour` INT NOT NULL DEFAULT (0),
	`is_cover` TINYINT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);




ALTER TABLE `tour_optional`
	CHANGE COLUMN `description_include` `description_include` TEXT NULL AFTER `tour_transfer_note`,
	CHANGE COLUMN `description_not_included` `description_not_included` TEXT NULL AFTER `description_include`;
/* Info: Records: 0  Duplicates: 0  Warnings: 0 */


ALTER TABLE tour_cut_off AUTO_INCREMENT = 0;

ALTER TABLE `tour_cut_off`
	CHANGE COLUMN `value` `value` FLOAT NULL DEFAULT NULL AFTER `name`;


	INSERT INTO tour_cut_off (name, value)
VALUES 
-- Insertar valores de 5 en 5 minutos hasta llegar a 1 hora (1h)
('Instant', 0),
('5 min', 5/60.0),
('10 min', 10/60.0),
('15 min', 15/60.0),
('20 min', 20/60.0),
('25 min', 25/60.0),
('30 min', 30/60.0),
('35 min', 35/60.0),
('40 min', 40/60.0),
('45 min', 45/60.0),
('50 min', 50/60.0),
('55 min', 55/60.0),
('1h', 1),

-- Insertar valores cada hora hasta llegar a 12 horas
('2h', 2),
('3h', 3),
('4h', 4),
('5h', 5),
('6h', 6),
('7h', 7),
('8h', 8),
('9h', 9),
('10h', 10),
('11h', 11),
('12h', 12),

-- Insertar valores para 24h, 48h, 72h, 96h
('24h', 24),
('48h', 48),
('72h', 72),
('96h', 96);



-- Extra Tables

CREATE TABLE `tour_extra_guide` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`id_type_guide` INT NOT NULL DEFAULT '0',
	`language` INT NOT NULL DEFAULT '0',
	`extra` VARCHAR(50) NOT NULL DEFAULT '0',
	`id_optional` INT NOT NULL DEFAULT (0),
	PRIMARY KEY (`id`)
);

ALTER TABLE `destination_guides` 
ADD COLUMN `is_featured` TINYINT NULL DEFAULT 0 AFTER `id_statuspost`;

CREATE TABLE `destination_guides_images` (
  `id` int NOT NULL AUTO_INCREMENT,
  `image_date` varchar(150) NOT NULL DEFAULT '0',
  `file_name` varchar(150) NOT NULL DEFAULT '0',
  `guid` varchar(150) NOT NULL DEFAULT '0',
  `caption` varchar(350) NOT NULL DEFAULT '',
  `id_destination_guides` int NOT NULL DEFAULT (0),
  `is_cover` tinyint NOT NULL DEFAULT (0),
  PRIMARY KEY (`id`)
);

CREATE TABLE `attractions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_city` int(11) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `keywords` varchar(250) DEFAULT NULL,
  `description` varchar(150) DEFAULT NULL,
  `canonicalurl` varchar(80) DEFAULT NULL,
  `slug` varchar(100) DEFAULT NULL,
  `is_active` tinyint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_attractions_city_idx` (`id_city`),
  CONSTRAINT `fk_attractions_city` FOREIGN KEY (`id_city`) REFERENCES `city` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

CREATE TABLE `city_summary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_city` int(11) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `id_statuspost` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_city_summary_city_idx` (`id_city`),
  KEY `fk_city_summary_statuspost1_idx` (`id_statuspost`),
  CONSTRAINT `fk_city_summary_city` FOREIGN KEY (`id_city`) REFERENCES `city` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_city_summary_statuspost1` FOREIGN KEY (`id_statuspost`) REFERENCES `statuspost` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ;

CREATE TABLE `city_summary_section` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `htmlcontent` text DEFAULT NULL,
  `section` varchar(45) DEFAULT NULL,
  `id_city_summary` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_city_summary_section_city_summary1_idx` (`id_city_summary`),
  CONSTRAINT `fk_city_summary_section_city_summary1` FOREIGN KEY (`id_city_summary`) REFERENCES `city_summary` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

CREATE TABLE tour_extra_guide_exceptions (
    id INT AUTO_INCREMENT PRIMARY KEY,
    id_extra_guide INT,
    exception_date DATE
);


ALTER TABLE `tour_booking_config`
	ADD COLUMN `free_cancelation` INT NULL AFTER `id_tour`;

-- ALTER TABLE `tour_details` 
--   ADD COLUMN instructions TEXT NULL,
--   ADD COLUMN additional_information TEXT NULL,
--   ADD COLUMN free_cancelation int NULL;


CREATE TABLE `widgets` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) DEFAULT NULL,
  `description` varchar(150) DEFAULT NULL,
  `script` text DEFAULT NULL,
  `active` tinyint(4) DEFAULT 1,
  PRIMARY KEY (`id`)
);

CREATE TABLE `widget_config` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_widget` int(11) NOT NULL,
  `parameter` varchar(100) DEFAULT NULL,
  `value` varchar(255) DEFAULT NULL,
  `type` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_widget` (`id_widget`),
  CONSTRAINT `fk_widget` FOREIGN KEY (`id_widget`) REFERENCES `widgets` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

ALTER TABLE `destination_guides_section` 
ADD COLUMN `title` VARCHAR(150) NULL DEFAULT NULL AFTER `htmlcontent`;

ALTER TABLE `destination_guides_section` 
ADD COLUMN `section_name` VARCHAR(80) NULL DEFAULT NULL AFTER `title`;

UPDATE destination_guides_section set section = 'informacion-principal-de' where section='main-information' and id > 0;
UPDATE destination_guides_section set section = 'que-ver-en' where section='what-to-see' and id > 0;
UPDATE destination_guides_section set section = 'atracciones-en' where section='attractions' and id > 0;
UPDATE destination_guides_section set section = 'antes-de-viajar-a' where section='before-traveling' and id > 0;
UPDATE destination_guides_section set section = 'donde-dormir-en' where section='where-to-stay' and id > 0;
UPDATE destination_guides_section set section = 'gastronomia-de' where section='gastronomy' and id > 0;

CREATE TABLE `pickups` (
  `id` VARCHAR(50) NOT NULL,
  `name` VARCHAR(80) NOT NULL,
  `description` VARCHAR(150) NULL,
  PRIMARY KEY (`id`));

INSERT INTO `pickups` (`id`, `name`) VALUES ('downtown', 'Downtown');
INSERT INTO `pickups` (`id`, `name`) VALUES ('outside', 'Outside the city');
INSERT INTO `pickups` (`id`, `name`) VALUES ('hoteldowntown', 'Hotel Downtown');





ALTER TABLE `tour_extra_vehicle` ADD COLUMN `id_optional` INT ;
ALTER TABLE `tour_extra_vehicle` ADD COLUMN `id_season` INT NULL AFTER `id_optional`;

ALTER TABLE `tour_extra_guide` ADD `id_season` INT NOT NULL AFTER `id_optional`;
ALTER TABLE `tour_extra_duration` ADD `id_optional` INT NOT NULL AFTER `active`;
ALTER TABLE `tour_booking_config` ADD `skip_line_type` INT NOT NULL AFTER `free_cancelation`, ADD `skip_line` INT NOT NULL AFTER `skip_line_type`;




ALTER TABLE `tour_extra_guide` ADD COLUMN `id_season` INT NULL AFTER `id_optional`;

ALTER TABLE `continent` 
ADD COLUMN `slug` VARCHAR(100) NULL AFTER `name`;

UPDATE `continent` SET `slug` = 'asia' WHERE (`id` = '1');
UPDATE `continent` SET `slug` = 'africa' WHERE (`id` = '2');
UPDATE `continent` SET `slug` = 'america' WHERE (`id` = '3');
UPDATE `continent` SET `slug` = 'antartida' WHERE (`id` = '4');
UPDATE `continent` SET `slug` = 'europa' WHERE (`id` = '5');
UPDATE `continent` SET `slug` = 'oceania' WHERE (`id` = '6');

ALTER TABLE `front_popular_destinations` 
ADD COLUMN `raiting` INT NULL DEFAULT NULL AFTER `position`;


CREATE TABLE `front_footer` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(200) NOT NULL,
  `menu_type` VARCHAR(45) NOT NULL,
  `slug` VARCHAR(150) NOT NULL,
  `canonicalurl` VARCHAR(200) NULL,
  PRIMARY KEY (`id`));


ALTER TABLE `tour_extra_attractions`
	ADD COLUMN `id_season` INT NULL AFTER `id_optional`;

  ALTER TABLE `tour_extra_custom`
	ADD COLUMN `id_season` INT NULL AFTER `id_optional`;

  
ALTER TABLE `tour_extra_duration`
	ADD COLUMN `id_season` INT NULL AFTER `id_optional`;
ALTER TABLE `tour_extra_equipment`
	ADD COLUMN `id_season` INT NULL AFTER `id_optional`;


  
ALTER TABLE `tour_extra_food`
	ADD COLUMN `id_season` INT NULL AFTER `id_optional`;

  
ALTER TABLE `tour_extra_vehicle`
	ADD COLUMN `id_season` INT NULL AFTER `id_optional`;


  

CREATE TABLE IF NOT EXISTS `tour_extra_duration_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_duration` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `tour_extra_vehicle_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_vehicle` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `tour_extra_guide_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_guide` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `tour_extra_attractions_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_attractions` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `tour_extra_custom_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_custom` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `tour_extra_equipment_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_equipment` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `tour_extra_metting_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_food` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);


CREATE TABLE IF NOT EXISTS `tour_extra_food_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_food` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE `tour_extra_meeting` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`address` INT NOT NULL DEFAULT '0',
	`extra` INT NOT NULL DEFAULT '0',
	`pickup` INT NOT NULL DEFAULT '0',
	`extra_pickup` INT NOT NULL DEFAULT '0',
	`latitud` INT NOT NULL DEFAULT '0',
	`longitude` INT NOT NULL DEFAULT '0',
	PRIMARY KEY (`id`)
);

ALTER TABLE `attractions` 
ADD COLUMN `htmlcontent` LONGTEXT NULL AFTER `slug`,
ADD COLUMN `section_name` VARCHAR(80) NULL AFTER `htmlcontent`,
ADD COLUMN `section` VARCHAR(80) NULL AFTER `section_name`;



-- DROP TABLE `tour_extra_metting`;
CREATE TABLE IF NOT EXISTS `tour_extra_metting` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `address` text NOT NULL,
  `extra` varchar(50) NOT NULL DEFAULT '0',
  `pickup` varchar(350) NOT NULL DEFAULT '0',
  `extra_pickup` varchar(350) NOT NULL DEFAULT '0',
  `latitud` varchar(150) NOT NULL DEFAULT '0',
  `longitude` varchar(150) NOT NULL DEFAULT '0',
  `id_optional` int(11) DEFAULT NULL,
  `id_season` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
);
DROP TABLE `attractions`;
CREATE TABLE `attractions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_city` int(11) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `id_statuspost` int(11) NOT NULL,
  `is_featured` tinyint(4) DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `fk_attractions_city_idx` (`id_city`),
  KEY `fk_attractions_statuspost1_idx` (`id_statuspost`),
  CONSTRAINT `fk_attractions_city` FOREIGN KEY (`id_city`) REFERENCES `city` (`id`),
  CONSTRAINT `fk_attractions_statuspost1` FOREIGN KEY (`id_statuspost`) REFERENCES `statuspost` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `attractions_images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `image_date` varchar(150) NOT NULL DEFAULT '0',
  `file_name` varchar(150) NOT NULL DEFAULT '0',
  `guid` varchar(150) NOT NULL DEFAULT '0',
  `caption` varchar(350) NOT NULL DEFAULT '',
  `id_attractions` int(11) NOT NULL DEFAULT 0,
  `is_cover` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

CREATE TABLE `attractions_section` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `htmlcontent` longtext DEFAULT NULL,
  `title` varchar(150) DEFAULT NULL,
  `section_name` varchar(80) DEFAULT NULL,
  `section` varchar(45) DEFAULT NULL,
  `id_attractions` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_attractions_section_attractions1_idx` (`id_attractions`),
  CONSTRAINT `fk_attractions_section_attractions1` FOREIGN KEY (`id_attractions`) REFERENCES `attractions` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `attractions_seo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `keywords` varchar(250) DEFAULT NULL,
  `description` varchar(150) DEFAULT NULL,
  `canonicalurl` varchar(80) DEFAULT NULL,
  `slug` varchar(100) DEFAULT NULL,
  `id_attractions_section` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_attractions_seo_attractions_section1_idx` (`id_attractions_section`),
  CONSTRAINT `fk_attractions_seo_attractions_section1` FOREIGN KEY (`id_attractions_section`) REFERENCES `attractions_section` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

ALTER TABLE `tour_rates` 
ADD COLUMN `id_currency` INT NOT NULL AFTER `id_tour_season`;


UPDATE tour_rates SET id_currency = 1 where id > 0;

UPDATE `continent` SET `name` = 'África' WHERE (`id` = '2');

UPDATE `country` SET `code` = 'eu', `name` = 'Estados Unidos de América' WHERE (`id` = '17');
UPDATE `country` SET `code` = 'stk' WHERE (`id` = '14');

ALTER TABLE `front_popular_attractions` 
ADD COLUMN `raiting` INT NULL AFTER `position`;



ALTER TABLE `tour_details`
	CHANGE COLUMN `short_description` `short_description` TEXT NULL COLLATE 'utf8mb4_general_ci' AFTER `name`;


CREATE TABLE `city_summary_images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `image_date` varchar(150) NOT NULL DEFAULT '0',
  `file_name` varchar(150) NOT NULL DEFAULT '0',
  `guid` varchar(150) NOT NULL DEFAULT '0',
  `caption` varchar(350) NOT NULL DEFAULT '',
  `id_city_summary` int(11) NOT NULL DEFAULT 0,
  `is_cover` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
);

ALTER TABLE `city_summary` 
ADD COLUMN `short_description` VARCHAR(255) NULL AFTER `id_statuspost`;



CREATE TABLE `country_summary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_country` int(11) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `id_statuspost` int(11) NOT NULL,
  `short_description` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_country_summary_country_idx` (`id_country`),
  KEY `fk_country_summary_statuspost1_idx` (`id_statuspost`),
  CONSTRAINT `fk_country_summary_country` FOREIGN KEY (`id_country`) REFERENCES `country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_country_summary_statuspost1` FOREIGN KEY (`id_statuspost`) REFERENCES `statuspost` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

CREATE TABLE `country_summary_images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `image_date` varchar(150) NOT NULL DEFAULT '0',
  `file_name` varchar(150) NOT NULL DEFAULT '0',
  `guid` varchar(150) NOT NULL DEFAULT '0',
  `caption` varchar(350) NOT NULL DEFAULT '',
  `id_country_summary` int(11) NOT NULL DEFAULT 0,
  `is_cover` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
);

CREATE TABLE `country_summary_section` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `htmlcontent` text DEFAULT NULL,
  `section` varchar(45) DEFAULT NULL,
  `id_country_summary` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_country_summary_section_country_summary1_idx` (`id_country_summary`),
  CONSTRAINT `fk_country_summary_section_country_summary1` FOREIGN KEY (`id_country_summary`) REFERENCES `country_summary` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

ALTER TABLE `tour_season` 
ADD COLUMN `active` TINYINT NULL DEFAULT 1 AFTER `id_tour_optional`,
ADD COLUMN `deleted` TINYINT NULL DEFAULT 0 AFTER `active`;


CREATE TABLE `subcategories` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(150) NOT NULL,
  `description` VARCHAR(180) NULL,
  `icon` VARCHAR(45) NULL,
  `slug` VARCHAR(45) NULL,
  `active` TINYINT NOT NULL DEFAULT 1,
  `id_category` INT NOT NULL,
  PRIMARY KEY (`id`));

ALTER TABLE `subcategories` 
ADD INDEX `fk_scat_1` (`id_category` ASC);
;
ALTER TABLE `subcategories` 
ADD CONSTRAINT `fk_scat_1`
  FOREIGN KEY (`id_category`)
  REFERENCES `categories` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE `tour_category` 
DROP FOREIGN KEY `fk_tcat_1`;
ALTER TABLE `tour_category` 
DROP INDEX `fk_tcat_1` ;

ALTER TABLE `tour_category` 
CHANGE COLUMN `id_category` `id_subcategory` INT(11) NOT NULL ,
ADD INDEX `fk_tcat_1_idx` (`id_subcategory` ASC);
;
ALTER TABLE `tour_category` 
ADD CONSTRAINT `fk_tcat_1`
  FOREIGN KEY (`id_subcategory`)
  REFERENCES `subcategories` (`id`);

ALTER TABLE `tour_extra_attractions` 
ADD COLUMN `margin` INT(3) NULL DEFAULT 0 AFTER `extra_pax_type`;
ALTER TABLE `tour_extra_attractions` 
ADD COLUMN `extra_margin` VARCHAR(250) NULL DEFAULT '0' AFTER `margin`;

CREATE TABLE `tour_extra_language` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_language` int(11) NOT NULL DEFAULT 0,
  `extra` varchar(50) NOT NULL DEFAULT '0',
  `id_optional` int(11) NOT NULL DEFAULT 0,
  `id_season` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE `tour_extra_language_exceptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_extra_language` int(11) DEFAULT NULL,
  `exception_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
);

INSERT INTO `tour_optional_extra` (`id`,`name`, `name_eng`, `active`, `name_key`) VALUES (2,'Lenguaje', 'Language', '1', '_language');


CREATE TABLE `tour_extra_attractions_tickets` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ticket_type` VARCHAR(80) NOT NULL AFTER `id`,
  `pax_type` INT(11) NOT NULL,
  `extra_pax_type` INT NOT NULL DEFAULT 0,
  `id_tour_extra_attractions` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
);

ALTER TABLE `tour_extra_metting` 
CHANGE COLUMN `address` `address` TEXT NULL ,
CHANGE COLUMN `extra` `extra` VARCHAR(50) NULL DEFAULT '0' ,
CHANGE COLUMN `pickup` `pickup` VARCHAR(350) NULL DEFAULT '0' ,
CHANGE COLUMN `extra_pickup` `extra_pickup` VARCHAR(350) NULL DEFAULT '0' ,
CHANGE COLUMN `latitud` `latitud` VARCHAR(150) NULL DEFAULT '0' ,
CHANGE COLUMN `longitude` `longitude` VARCHAR(150) NULL DEFAULT '0' ;

ALTER TABLE `destination_guides_seo` 
CHANGE COLUMN `keywords` `keywords` VARCHAR(500) NULL DEFAULT NULL ,
CHANGE COLUMN `description` `description` VARCHAR(250) NULL DEFAULT NULL ,
CHANGE COLUMN `canonicalurl` `canonicalurl` VARCHAR(250) NULL DEFAULT NULL ,
CHANGE COLUMN `slug` `slug` VARCHAR(250) NULL DEFAULT NULL ;



ALTER TABLE `tour_extra_attractions_tickets` 
ADD COLUMN `id_currency` INT(11) NULL AFTER `id_tour_extra_attractions`,
CHANGE COLUMN `pax_type` `pax_type` INT(11) UNSIGNED NOT NULL ,
ADD INDEX `fk_teat_0` (`pax_type` ASC) ,
ADD INDEX `fk_teat_1` (`id_currency` ASC) ;
;
ALTER TABLE `tour_extra_attractions_tickets` 
ADD CONSTRAINT `fk_teat_0`
  FOREIGN KEY (`pax_type`)
  REFERENCES `tour_pax_type` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_teat_1`
  FOREIGN KEY (`id_currency`)
  REFERENCES `currency` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE `tour_extra_attractions` 
ADD COLUMN `duration` VARCHAR(11) NULL AFTER `id_season`,
ADD COLUMN `id_tour_duration_type` INT(11) NULL AFTER `duration`;

CREATE TABLE `tour_rates_group` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_tour_rates` int(10) unsigned NOT NULL,
  `num_paxes` int(11) NOT NULL,
  `price` varchar(50) DEFAULT NULL,
  `id_currency` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_trg_0` (`id_tour_rates`),
  CONSTRAINT `fk_trg_0` FOREIGN KEY (`id_tour_rates`) REFERENCES `tour_rates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

ALTER TABLE tour_booking
	ADD COLUMN payment_status VARCHAR(150) NULL DEFAULT NULL AFTER confirmation,
	ADD COLUMN stripe_id VARCHAR(150) NULL DEFAULT NULL AFTER payment_status;
  
  
ALTER TABLE `tour_booking_rates` 
CHANGE COLUMN `rate_exchange` `rate_exchange` INT NULL DEFAULT 0 ;


CREATE TABLE `icons` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(150) DEFAULT NULL,
  `type` varchar(50) DEFAULT NULL,
  `icon` mediumtext,
  PRIMARY KEY (`id`)
) ;
INSERT INTO `icons` VALUES (1,'Religioso','Building','<svg fill=\"#233F80\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" stroke=\"#172173\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"><path d=\"M10 22v-4a2 2 0 0 1 4 0v4h4V12a1 1 0 0 0-.485-.857L13 8.434V6h2V4h-2V2h-2v2H9v2h2v2.434l-4.515 2.709A1 1 0 0 0 6 12v10h4zm-7 0h2v-8.118l-2.447 1.224A.998.998 0 0 0 2 16v5a1 1 0 0 0 1 1zm18.447-6.895L19 13.882V22h2a1 1 0 0 0 1-1v-5c0-.379-.214-.725-.553-.895z\"></path></g></svg>'),(2,'Entretenimiento','Thing','<svg fill=\"#233F80\" aria-hidden=\"true\" xmlns=\"http://www.w3.org/2000/svg\" width=\"50\" height=\"50\" fill=\"currentColor\" viewBox=\"0 0 24 24\">   <path d=\"M4 5a2 2 0 0 0-2 2v2.5a1 1 0 0 0 1 1 1.5 1.5 0 1 1 0 3 1 1 0 0 0-1 1V17a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2.5a1 1 0 0 0-1-1 1.5 1.5 0 1 1 0-3 1 1 0 0 0 1-1V7a2 2 0 0 0-2-2H4Z\"/> </svg>'),(3,'Diversión','Fun','<svg fill=\"#233F80\" height=\"100px\" width=\"100px\" version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 512 512\" xml:space=\"preserve\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"> <g> <g> <path d=\"M389.565,478.609h-21.66l-22.962-63.781c-4.592,2.064-9.226,4.038-13.943,5.77c-13.751,28.065-42.642,46.88-75,46.88 s-61.25-18.815-75-46.88c-4.72-1.733-9.353-3.709-13.942-5.773l-22.963,63.784h-21.66c-9.217,0-16.696,7.479-16.696,16.696 c0,9.217,7.479,16.696,16.696,16.696h267.13c9.217,0,16.696-7.479,16.696-16.696C406.261,486.087,398.782,478.609,389.565,478.609 z\"></path> </g> </g> <g> <g> <path d=\"M432.85,167.956c-3.984-14.409-9.696-28.193-17.084-41.222c12.734-19.052,11.19-45.68-6.288-63.159 c-17.421-17.421-44.015-19.096-63.171-6.301c-13.027-7.387-26.811-13.098-41.22-17.083C300.479,17.299,280.231,0,256,0 s-44.479,17.298-49.087,40.192c-14.411,3.985-28.193,9.697-41.22,17.084c-19.051-12.734-45.682-11.191-63.161,6.289 c-17.422,17.422-19.095,44.015-6.302,63.172c-7.386,13.027-13.098,26.811-17.082,41.219 c-22.892,4.608-40.191,24.856-40.191,49.087c0,24.232,17.299,44.48,40.193,49.087c3.984,14.409,9.696,28.191,17.082,41.219 c-12.696,19.012-11.226,45.645,6.291,63.161c17.387,17.387,43.98,19.124,63.174,6.302c13.027,7.386,26.809,13.098,41.217,17.082 c4.607,22.894,24.855,40.192,49.086,40.192s44.479-17.299,49.087-40.192c14.409-3.985,28.193-9.696,41.22-17.083 c19.01,12.698,45.644,11.226,63.161-6.29c17.421-17.421,19.098-44.019,6.302-63.174c7.387-13.026,13.098-26.808,17.082-41.217 c22.892-4.608,40.191-24.855,40.191-49.087C473.043,192.812,455.745,172.564,432.85,167.956z M123.217,146.635 c11.719,3.611,23.46,3.506,36.193-2.571l51.522,51.521c-0.74,1.547-1.361,3.134-1.943,4.764h-72.934 c-4.231-11.862-12.748-21.561-23.75-27.393C115.086,163.848,118.732,155.054,123.217,146.635z M159.41,290.023 c-12.784-6.102-24.536-6.163-36.193-2.572c-4.486-8.418-8.129-17.212-10.913-26.319c11.002-5.832,19.519-15.531,23.75-27.393 h72.934c0.581,1.63,1.202,3.217,1.943,4.764L159.41,290.023z M239.304,336.992c-11.862,4.227-21.561,12.744-27.394,23.748 c-9.106-2.784-17.9-6.428-26.318-10.912c3.608-11.72,3.505-23.46-2.573-36.194l51.522-51.521c1.546,0.74,3.134,1.361,4.764,1.942 V336.992z M239.304,170.034c-1.63,0.581-3.218,1.202-4.764,1.942l-51.522-51.521c6.062-12.698,6.195-24.432,2.573-36.194 c8.418-4.484,17.212-8.129,26.318-10.913c5.833,11.002,15.532,19.519,27.394,23.749V170.034z M352.59,144.063 c12.697,6.06,24.43,6.195,36.193,2.571c4.486,8.419,8.131,17.212,10.913,26.32c-11.002,5.832-19.519,15.531-23.75,27.393h-72.934 c-0.581-1.63-1.202-3.217-1.943-4.764L352.59,144.063z M272.696,97.097c11.862-4.23,21.561-12.747,27.394-23.75 c9.106,2.784,17.9,6.429,26.319,10.913c-3.601,11.695-3.521,23.431,2.572,36.194l-51.522,51.521 c-1.546-0.74-3.134-1.361-4.764-1.942V97.097z M326.409,349.825c-8.42,4.484-17.213,8.13-26.319,10.913 c-5.833-11.002-15.533-19.519-27.394-23.749v-72.937c1.629-0.581,3.218-1.202,4.764-1.942l51.522,51.521 C322.907,326.356,322.796,338.089,326.409,349.825z M388.783,287.451c-11.715-3.61-23.456-3.506-36.193,2.572l-51.522-51.521 c0.74-1.547,1.361-3.134,1.943-4.764h72.934c4.231,11.862,12.748,21.561,23.75,27.393 C396.912,270.239,393.268,279.033,388.783,287.451z\"></path> </g> </g> </g></svg>'),(4,'Museo','Building','<svg fill=\"#233F80\" width=\"100px\" height=\"100px\" viewBox=\"0 0 50 50\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"><path d=\"M25 1.9980469C24.8425 1.9980469 24.684062 2.034375 24.539062 2.109375L3.5390625 13.109375C3.2090625 13.289375 3 13.63 3 14L3 16L47 16L47 14C47 13.63 46.790937 13.289375 46.460938 13.109375L25.460938 2.109375C25.315938 2.034375 25.1575 1.9980469 25 1.9980469 z M 5 18L5 19.400391C5 20.650391 5.84 21.669687 7 21.929688L7 38L15 38L15 21.929688C16.16 21.669688 17 20.650391 17 19.400391L17 18L5 18 z M 19 18L19 19.400391C19 20.650391 19.84 21.669687 21 21.929688L21 38L29 38L29 21.929688C30.16 21.669688 31 20.650391 31 19.400391L31 18L19 18 z M 33 18L33 19.400391C33 20.650391 33.84 21.669687 35 21.929688L35 38L43 38L43 21.929688C44.16 21.669688 45 20.650391 45 19.400391L45 18L33 18 z M 4 40C3.56 40 3.0707031 40.159219 2.7207031 40.449219C2.2607031 40.839219 2 41.419297 2 42.029297L2 44.779297C2 46.019297 2.9196094 47 4.0996094 47L45.800781 47C46.960781 47 47.900391 46.050859 47.900391 44.880859L47.900391 42.130859C47.900391 40.960859 46.960781 40.009766 45.800781 40.009766C45.800781 40.009766 4.08 40 4 40 z\"></path></g></svg>'),(5,'Atracción','Map','<svg fill=\"#233F80\" height=\"100px\" width=\"100px\" version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 512.014 512.014\" xml:space=\"preserve\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"> <g transform=\"translate(0 -1)\"> <g> <g> <path d=\"M511.596,487.499L468.93,274.166c-2.005-9.963-10.752-17.152-20.928-17.152h-82.923c1.707-2.645,3.392-5.355,5.077-8 l12.16-19.136c15.061-23.808,23.019-51.307,23.019-79.531c0-42.496-18.176-83.115-49.92-111.445 C323.714,10.592,281.047-2.975,238.551,2.017C172.183,9.569,117.335,63.03,108.162,129.121 c-5.44,39.168,4.352,78.059,27.541,109.547c4.395,5.952,8.341,12.224,12.523,18.347H64.002c-10.155,0-18.901,7.189-20.907,17.152 L0.428,487.499c-1.259,6.272,0.363,12.757,4.416,17.707c4.053,4.928,10.091,7.808,16.491,7.808h469.333 c6.4,0,12.437-2.88,16.512-7.808C511.212,500.257,512.834,493.771,511.596,487.499z M256.002,86.347c35.307,0,64,28.715,64,64 c0,35.285-28.693,64-64,64c-35.285,0-64-28.715-64-64C192.002,115.062,220.716,86.347,256.002,86.347z M47.362,470.347 l34.133-170.667h93.845c0.064,0.107,0.128,0.235,0.192,0.341c13.696,23.232,26.411,47.019,38.016,69.547 c4.907,9.621,9.813,19.2,14.699,28.949l8.683,17.365c3.627,7.232,10.987,11.797,19.072,11.797 c8.085,0,15.467-4.565,19.093-11.797l18.389-36.779c4.928-9.835,10.176-19.584,15.531-29.291 c1.536-2.773,3.072-5.568,4.608-8.299c4.544-8.021,9.195-16.021,13.931-23.936c3.669-6.144,7.296-12.139,10.859-17.899h92.117 l34.133,170.667H47.362z\"></path> <path d=\"M256.008,171.681c11.776,0,21.333-9.557,21.333-21.333s-9.557-21.333-21.333-21.333 c-11.776,0-21.333,9.557-21.333,21.333S244.232,171.681,256.008,171.681z\"></path> </g> </g> </g> </g></svg>'),(6,'Alimentación','Food','<svg fill=\"#233F80\" height=\"100px\" width=\"100px\" version=\"1.1\" id=\"Icons\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 32 32\" xml:space=\"preserve\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"> <g> <circle cx=\"12\" cy=\"16\" r=\"5\"></circle> <path d=\"M12,6C6.5,6,2,10.5,2,16s4.5,10,10,10s10-4.5,10-10S17.5,6,12,6z M12,23c-3.9,0-7-3.1-7-7s3.1-7,7-7s7,3.1,7,7 S15.9,23,12,23z\"></path> <path d=\"M30,10.5V5c0-0.6-0.4-1-1-1s-1,0.4-1,1v5.5c0,0.2,0,0.4,0,0.5h-1V5c0-0.6-0.4-1-1-1s-1,0.4-1,1v6h-1c0-0.2,0-0.4,0-0.5V5 c0-0.6-0.4-1-1-1s-1,0.4-1,1v5.5c0,1.9,0.5,3.4,1.4,4.3c0.7,0.8,1,1.8,0.9,2.7l-1,7.3c-0.1,0.8,0.1,1.6,0.6,2.2S25.2,28,26,28 s1.5-0.3,2.1-0.9s0.8-1.4,0.6-2.2l-1-7.3c-0.1-1,0.2-2,0.9-2.8C29.5,13.8,30,12.3,30,10.5z\"></path> </g> </g></svg>'),(7,'Transporte','Transportation','<svg width=\"100px\" height=\"100px\" viewBox=\"0 0 24 24\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"#233F80233F80\" stroke=\"#233F80233F80\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"> <title>bus_2_fill</title> <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"> <g id=\"Transport\" transform=\"translate(-144.000000, -48.000000)\"> <g id=\"bus_2_fill\" transform=\"translate(144.000000, 48.000000)\"> <path d=\"M24,0 L24,24 L0,24 L0,0 L24,0 Z M12.5934901,23.257841 L12.5819402,23.2595131 L12.5108777,23.2950439 L12.4918791,23.2987469 L12.4918791,23.2987469 L12.4767152,23.2950439 L12.4056548,23.2595131 C12.3958229,23.2563662 12.3870493,23.2590235 12.3821421,23.2649074 L12.3780323,23.275831 L12.360941,23.7031097 L12.3658947,23.7234994 L12.3769048,23.7357139 L12.4804777,23.8096931 L12.4953491,23.8136134 L12.4953491,23.8136134 L12.5071152,23.8096931 L12.6106902,23.7357139 L12.6232938,23.7196733 L12.6232938,23.7196733 L12.6266527,23.7031097 L12.609561,23.275831 C12.6075724,23.2657013 12.6010112,23.2592993 12.5934901,23.257841 L12.5934901,23.257841 Z M12.8583906,23.1452862 L12.8445485,23.1473072 L12.6598443,23.2396597 L12.6498822,23.2499052 L12.6498822,23.2499052 L12.6471943,23.2611114 L12.6650943,23.6906389 L12.6699349,23.7034178 L12.6699349,23.7034178 L12.678386,23.7104931 L12.8793402,23.8032389 C12.8914285,23.8068999 12.9022333,23.8029875 12.9078286,23.7952264 L12.9118235,23.7811639 L12.8776777,23.1665331 C12.8752882,23.1545897 12.8674102,23.1470016 12.8583906,23.1452862 L12.8583906,23.1452862 Z M12.1430473,23.1473072 C12.1332178,23.1423925 12.1221763,23.1452606 12.1156365,23.1525954 L12.1099173,23.1665331 L12.0757714,23.7811639 C12.0751323,23.7926639 12.0828099,23.8018602 12.0926481,23.8045676 L12.108256,23.8032389 L12.3092106,23.7104931 L12.3186497,23.7024347 L12.3186497,23.7024347 L12.3225043,23.6906389 L12.340401,23.2611114 L12.337245,23.2485176 L12.337245,23.2485176 L12.3277531,23.2396597 L12.1430473,23.1473072 Z\" id=\"MingCute\" fill-rule=\"nonzero\"> </path> <path d=\"M4,5 C2.34315,5 1,6.34315 1,8 L1,16 C1,17.1046 1.89543,18 3,18 L3.17071,18 C3.58254,19.1652 4.69378,20 6,20 C7.30622,20 8.41746,19.1652 8.82929,18 L15.1707,18 C15.5825,19.1652 16.6938,20 18,20 C19.3062,20 20.4175,19.1652 20.8293,18 L21,18 C22.1046,18 23,17.1046 23,16 L23,9.60555 C23,9.01328 22.8247,8.43425 22.4962,7.94145 L21.4258,6.3359 C20.8694,5.5013 19.9327,5 18.9296,5 L4,5 Z M3,8 C3,7.44772 3.44772,7 4,7 L6,7 L6,10 L3,10 L3,8 Z M11,7 L8,7 L8,10 L11,10 L11,7 Z M13,10 L16,10 L16,7 L13,7 L13,10 Z M21,11 L21,9.60555 C21,9.40813 20.9416,9.21512 20.8321,9.05085 L19.7617,7.4453 C19.5762,7.1671 19.264,7 18.9296,7 L18,7 L18,11 L21,11 Z M18,16 C18.5523,16 19,16.4477 19,17 C19,17.5523 18.5523,18 18,18 C17.4477,18 17,17.5523 17,17 C17,16.4477 17.4477,16 18,16 Z M7,17 C7,16.4477 6.55228,16 6,16 C5.44772,16 5,16.4477 5,17 C5,17.5523 5.44772,18 6,18 C6.55228,18 7,17.5523 7,17 Z\" fill=\"#233F80\"> </path> </g> </g> </g> </g></svg>'),(8,'Monumento','Building','<svg version=\"1.1\" id=\"_x32_\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 512 512\" xml:space=\"preserve\" width=\"100px\" height=\"100px\" fill=\"#233F80\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"> <style type=\"text/css\"> .st0{fill:#233F80;} </style> <g> <path class=\"st0\" d=\"M326.416,189.318c9.647-31.671,3-52.064-10.607-69.498c-15.557-19.926-43.35-25.384-58.948-39.761 c5.401-0.459,9.696-4.86,9.696-10.385c0-5.827-4.73-10.557-10.557-10.557c-5.827,0-10.557,4.73-10.557,10.557 c0,5.524,4.295,9.926,9.696,10.385c-15.598,14.377-43.392,19.836-58.949,39.761c-13.606,17.434-20.253,37.827-10.606,69.498 H326.416z\"></path> <path class=\"st0\" d=\"M327.26,391.163V201.285H184.74v189.879h43.67V315.65h0.074c0.377-5.393,2.459-9.696,5.508-13.598 c5.82-7.458,16.328-9.393,22.008-14.893c5.68,5.5,16.188,7.434,22.008,14.893c3.049,3.902,5.131,8.205,5.508,13.598h0.074v75.514 H327.26z\"></path> <path class=\"st0\" d=\"M256,56.478c3.402,0,6.164-2.755,6.164-6.156c0-3.402-2.762-6.164-6.164-6.164 c-3.402,0-6.156,2.762-6.156,6.164C249.844,53.723,252.598,56.478,256,56.478z\"></path> <path class=\"st0\" d=\"M10.066,391.163h44.859l-1.878-101.996h5.615v-8.5h-5.77l-0.762-41.45h6.532v-8.508h-6.688l-0.746-40.384 h3.048v-8.5h-3.983v-14.884h3.983v-8.5h-3.72c0-9.975-8.082-18.073-18.066-18.073c-9.974,0-18.065,8.098-18.065,18.073h-3.721v8.5 h3.983v14.884h-3.983v8.5h3.058l-0.746,40.384H6.32v8.508h6.541l-0.763,41.45H6.32v8.5h5.623L10.066,391.163z M41.794,181.826 h-5.048v-14.884h5.048V181.826z M23.188,166.941h5.058v14.884h-5.058V166.941z\"></path> <path class=\"st0\" d=\"M457.084,391.163h44.859l-1.877-101.996h5.615v-8.5h-5.77l-0.763-41.45h6.533v-8.508h-6.688l-0.746-40.384 h3.049v-8.5h-3.983v-14.884h3.983v-8.5h-3.721c0-9.975-8.09-18.073-18.065-18.073c-9.975,0-18.065,8.098-18.065,18.073h-3.721v8.5 h3.983v14.884h-3.983v8.5h3.049l-0.746,40.384h-6.688v8.508h6.533l-0.763,41.45h-5.77v8.5h5.615L457.084,391.163z M488.812,181.826 h-5.05v-14.884h5.05V181.826z M470.206,166.941h5.057v14.884h-5.057V166.941z\"></path> <path class=\"st0\" d=\"M110.776,391.163h17.228v-24.884h0.033c0.172-2.418,1.107-4.353,2.475-6.107 c2.615-3.352,7.336-4.212,9.886-6.688c2.557,2.475,7.27,3.336,9.884,6.688c1.369,1.754,2.303,3.689,2.475,6.107h0.033v24.884 h20.156V251.561h-0.057v-12.884h3.778c4.967-16.311,1.541-26.819-5.467-35.794c-8.147-10.442-22.852-13.138-30.802-20.844 c-7.951,7.705-22.655,10.402-30.802,20.844c-7.008,8.976-10.434,19.483-5.468,35.794h3.655v14.983L86.58,268.561v122.602h21.262 H110.776z M152.79,324.666h-24.786v-24.885h0.033c0.172-2.417,1.107-4.36,2.475-6.106c2.615-3.344,7.336-4.214,9.886-6.688 c2.557,2.475,7.27,3.344,9.884,6.688c1.369,1.746,2.303,3.689,2.475,6.106h0.033V324.666z M160.577,251.561h-14.082v-12.884h14.082 V251.561z M134.176,238.677v12.884h-14.074v-12.884H134.176z\"></path> <path class=\"st0\" d=\"M339.112,238.677v12.884h-0.058v139.602h20.156v-24.884h0.033c0.172-2.418,1.106-4.353,2.475-6.107 c2.614-3.352,7.328-4.212,9.885-6.688c2.549,2.475,7.27,3.336,9.885,6.688c1.369,1.754,2.303,3.689,2.475,6.107h0.033v24.884 h17.228h2.935h21.262V268.561l-21.204-14.901v-14.983h3.655c4.967-16.311,1.541-26.819-5.467-35.794 c-8.147-10.442-22.852-13.138-30.802-20.844c-7.951,7.705-22.656,10.402-30.803,20.844c-7.008,8.976-10.434,19.483-5.466,35.794 H339.112z M351.424,251.561v-12.884h14.081v12.884H351.424z M383.996,324.666H359.21v-24.885h0.033 c0.172-2.417,1.106-4.36,2.475-6.106c2.614-3.344,7.328-4.214,9.885-6.688c2.549,2.475,7.27,3.344,9.885,6.688 c1.369,1.746,2.303,3.689,2.475,6.106h0.033V324.666z M391.897,251.561h-14.073v-12.884h14.073V251.561z\"></path> <rect y=\"397.467\" class=\"st0\" width=\"512\" height=\"70.375\"></rect> </g> </g></svg>');


ALTER TABLE `icons` 
ADD COLUMN `active` TINYINT(1) DEFAULT 1;

ALTER TABLE `tour_extra_attractions` 
ADD COLUMN `id_icon` INT,
ADD INDEX `fk_tea1` (`id_icon` ASC);
;
ALTER TABLE `tour_extra_attractions` 
ADD CONSTRAINT `fk_tea1`
  FOREIGN KEY (`id_icon`)
  REFERENCES `icons` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE `tour_extra_attractions_tickets` 
ADD COLUMN `id_icon` INT,
ADD INDEX `fk_teat1` (`id_icon` ASC);
;
ALTER TABLE `tour_extra_attractions_tickets` 
ADD CONSTRAINT `fk_teat1`
  FOREIGN KEY (`id_icon`)
  REFERENCES `icons` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;


UPDATE `tour_extras` SET `name` = 'Desayuno', `name_eng` = 'Breakfast' WHERE (`id` = '19');
UPDATE `tour_extras` SET `active` = '0' WHERE (`id` = '20');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`, `active`) VALUES ('Almuerzo', 'Brunch', 'food', '1');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`, `active`) VALUES ('Cena', 'Dinner', 'food', '1');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`, `active`) VALUES ('Merienda', 'Lunch', 'food', '1');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`, `active`) VALUES ('Snacks', 'Snacks', 'food', '1');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`, `active`) VALUES ('Degustación', 'Tasting', 'food', '1');

ALTER TABLE `tour_extra_food` 
ADD COLUMN `description` VARCHAR(150) NULL AFTER `id_season`;



ALTER TABLE `tour_images` 
ADD COLUMN `order` INT NULL DEFAULT NULL AFTER `is_cover`;


ALTER TABLE `categories` 
DROP COLUMN `icon`,
DROP COLUMN `description`;
ALTER TABLE `categories` 
CHANGE COLUMN `slug` `slug` VARCHAR(160) NULL DEFAULT NULL ;

ALTER TABLE `subcategories` 
DROP COLUMN `icon`,
DROP COLUMN `description`;
ALTER TABLE `subcategories` 
CHANGE COLUMN `slug` `slug` VARCHAR(160) NULL DEFAULT NULL ;



ALTER TABLE `company`
	ADD COLUMN `isDefault` INT NULL DEFAULT '0' AFTER `comertial_name`;

ALTER TABLE `company` ADD `comertial_email` VARCHAR(180) NULL DEFAULT NULL AFTER `comertial_name`, ADD `financial_email` VARCHAR(180) NULL DEFAULT NULL AFTER `comertial_email`, ADD `booking_email` VARCHAR(180) NULL DEFAULT NULL AFTER `financial_email`, ADD `is_active` INT NOT NULL DEFAULT '0' AFTER `booking_email`, ADD `address` TEXT NOT NULL AFTER `is_active`;


CREATE TABLE `tour_itinerary` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`stop_name` VARCHAR(280) NOT NULL DEFAULT '0',
	`tags` TEXT DEFAULT '',
	`address` TEXT DEFAULT NULL,
	`duration` VARCHAR(50) NOT NULL DEFAULT '',
	`latitude`  VARCHAR(50) NOT NULL DEFAULT '',
	`longitude` VARCHAR(50) NOT NULL DEFAULT '',
  `order` INT NOT NULL DEFAULT 0,
  `id_tour_details` INT NOT NULL,
	PRIMARY KEY (`id`)
);


ALTER TABLE `tour_itinerary`
	ADD COLUMN `description` VARCHAR(180) NULL DEFAULT NULL AFTER `stop_name`;

  CREATE TABLE `tour_booking_extra` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `extra` VARCHAR(360) NOT NULL DEFAULT '',
    `pax` VARCHAR(360) NOT NULL DEFAULT '',
    `price` VARCHAR(100) NOT NULL DEFAULT '0',
    `type` VARCHAR(50) NOT NULL DEFAULT '',
    `id_tour_booking` INT NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`)
);


ALTER TABLE `tour_booking_config`
	ADD COLUMN `use_system` INT(1) NULL DEFAULT '0' AFTER `skip_line`;



  CREATE TABLE `tour_external` (
	`id` INT NOT NULL AUTO_INCREMENT,
	`item_id` VARCHAR(280) NOT NULL DEFAULT '0',
	`image` TEXT NOT NULL,
	`name` TEXT NOT NULL,
	`description` TEXT NOT NULL,
	`id_tour` TEXT NOT NULL,
	PRIMARY KEY (`id`)
);

ALTER TABLE `tour_external`
	ADD COLUMN `channel` VARCHAR(50) NULL DEFAULT NULL AFTER `id_tour`;


  CREATE TABLE third_party_credentials (
    id INT AUTO_INCREMENT PRIMARY KEY, 
    id_company INT NOT NULL,          
    provider_name VARCHAR(50) NOT NULL, 
    key_name VARCHAR(50) NOT NULL,    
    key_value TEXT NOT NULL,         
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    UNIQUE (id_company, provider_name, key_name) 
);


ALTER TABLE `tour_external`
	CHANGE COLUMN `id_tour` `id_tour` INT NOT NULL DEFAULT 0 AFTER `description`,
	ADD COLUMN `id_availability` INT NULL AFTER `channel`;


ALTER TABLE `tour_external`
	ADD COLUMN `company` VARCHAR(250) NOT NULL DEFAULT '' AFTER `id_availability`;

ALTER TABLE `tour_external`
	ADD COLUMN `company_name` VARCHAR(250) NOT NULL DEFAULT '' AFTER `company`;


  ALTER TABLE `tour_external`
	ADD COLUMN `currency` VARCHAR(50) NULL DEFAULT NULL AFTER `id_availability`;


  ALTER TABLE `widgets`
	ADD COLUMN `id_company` INT NULL AFTER `active`;

  UPDATE widgets SET id_company = 1;  -- set all widgets to company 1 (trekzy)


  ALTER TABLE `tour_booking_rates`
	ADD COLUMN `unpaid` VARCHAR(180) NULL DEFAULT NULL AFTER `discount`;



  CREATE TABLE exchange_rates (
    id INT AUTO_INCREMENT PRIMARY KEY,
    currency_code VARCHAR(3) NOT NULL UNIQUE,
    rate DECIMAL(15,6) NOT NULL,
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);



CREATE TABLE IF NOT EXISTS `tour_external_minimal` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` varchar(50) DEFAULT NULL,
  `price` varchar(50) DEFAULT NULL,
  `tour_id` int(11) DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  `currency` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
);

UPDATE destination_guides_section SET section_name = 'Atracciones', section = 'atracciones-en', title = REPLACE(title, 'Excursiones', 'Atracciones') where section = 'excursiones-de';
UPDATE destination_guides_section SET section_name = 'Antes de viajar', section = 'antes-de-viajar-a', title = REPLACE(title, 'Qué hacer en', 'Antes de viajar a') where section = 'que-hacer-en';

UPDATE destination_guides_seo SET canonicalurl = REPLACE(canonicalurl, 'excursiones-de', 'atracciones-en'), slug = REPLACE(slug, 'excursiones-de', 'atracciones-en') where slug LIKE 'excursiones-de%';
UPDATE destination_guides_seo SET canonicalurl = REPLACE(canonicalurl, 'que-hacer-en', 'antes-de-viajar-a'), slug = REPLACE(slug, 'que-hacer-en', 'antes-de-viajar-a') where slug LIKE 'que-hacer-en%';


ALTER TABLE `tour_itinerary` 
ADD COLUMN `id_tour_duration_type` INT NULL AFTER `duration`;
ALTER TABLE `tour_itinerary` 
ADD INDEX `tour_i_fk1` (`id_tour_duration_type` ASC);
;
ALTER TABLE `tour_itinerary` 
ADD CONSTRAINT `tour_i_fk1`
  FOREIGN KEY (`id_tour_duration_type`)
  REFERENCES `tour_duration_type` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE `attractions_seo` 
CHANGE COLUMN `canonicalurl` `canonicalurl` VARCHAR(250) NULL DEFAULT NULL ,
CHANGE COLUMN `slug` `slug` VARCHAR(200) NULL DEFAULT NULL ;

ALTER TABLE `tour_extra_language` 
ADD INDEX `tour_extra_language_i_idx1` (`id_language` ASC);
;
ALTER TABLE `tour_extra_language` 
ADD CONSTRAINT `tour_extra_language_i_fk1`
  FOREIGN KEY (`id_language`)
  REFERENCES `languages` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE `tour_extra_language_exceptions` 
ADD INDEX `idx_tel1` (`id_extra_language` ASC);
;
ALTER TABLE `tour_extra_language_exceptions` 
ADD CONSTRAINT `fk_tel1`
  FOREIGN KEY (`id_extra_language`)
  REFERENCES `tour_extra_language` (`id`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;


ALTER TABLE `users` 
ADD COLUMN `deleted` TINYINT(1) NULL DEFAULT '0' AFTER `id_agency`;

CREATE TABLE `attractions_alternatives` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `id_attractions` INT NOT NULL,
  `id_city` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `attractions_alternatives_idx_1` (`id_attractions` ASC),
  INDEX `attractions_alternatives_idx_2` (`id_city` ASC) ,
  CONSTRAINT `attractions_alternatives_fk_1`
    FOREIGN KEY (`id_attractions`)
    REFERENCES `attractions` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `attractions_alternatives_fk_2`
    FOREIGN KEY (`id_city`)
    REFERENCES `city` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);

    ALTER TABLE tour_itinerary MODIFY COLUMN address TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;



ALTER TABLE `categories` 
ADD COLUMN `name_en` VARCHAR(150) NULL DEFAULT NULL AFTER `name`;


ALTER TABLE `country_summary` 
ADD COLUMN `title_en` VARCHAR(150) NULL AFTER `title`,
ADD COLUMN `short_description_en` VARCHAR(255) NULL AFTER `short_description`,
CHANGE COLUMN `title` `title` VARCHAR(150) NULL DEFAULT NULL ;

ALTER TABLE `country_summary_images` 
ADD COLUMN `caption_en` VARCHAR(350) NULL AFTER `is_cover`;

ALTER TABLE `country_summary_section` 
ADD COLUMN `htmlcontent_en` MEDIUMTEXT NULL DEFAULT NULL AFTER `id_country_summary`;
ALTER TABLE `country_summary_section` 
ADD COLUMN `section_en` VARCHAR(45) NULL DEFAULT NULL AFTER `section`;

UPDATE `tour_extras` SET `name` = '3-6 Horas', `name_eng` = '3-6 Hours' WHERE (`id` = '1');
UPDATE `tour_extras` SET `name` = '6-9 Horas', `name_eng` = '6-9 Hours' WHERE (`id` = '2');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`) VALUES ('12-15 Horas', '12-15 Hours', 'duration');
UPDATE `tour_extras` SET `name` = '9-12 Horas', `name_eng` = '9-12 Hours' WHERE (`id` = '3');
INSERT INTO `tour_extras` (`name`, `name_eng`, `type`) VALUES ('1-3 Horas', '1-3 Hours', 'duration');
UPDATE `tour_extras` SET `active` = '1' WHERE (`id` = '28');
UPDATE `tour_extras` SET `active` = '1' WHERE (`id` = '29');

ALTER TABLE `statuspost` 
ADD COLUMN `name_en` VARCHAR(45) NULL DEFAULT NULL AFTER `name`;
UPDATE `statuspost` SET `name` = 'Inactivo', `name_en` = 'Inactive' WHERE (`id` = '0');
UPDATE `statuspost` SET `name` = 'Borrador', `name_en` = 'Draft' WHERE (`id` = '1');
UPDATE `statuspost` SET `name` = 'Publicado', `name_en` = 'Published' WHERE (`id` = '2');

INSERT INTO `tour_cut_off` (`name`, `value`) VALUES ('7 días', '168');
INSERT INTO `tour_cut_off` (`name`, `value`) VALUES ('15 días', '360');
INSERT INTO `tour_cut_off` (`name`, `value`) VALUES ('30 días', '720');

ALTER TABLE `languages` 
ADD COLUMN `name_en` VARCHAR(180) NULL DEFAULT NULL AFTER `name`;

ALTER TABLE `currency` 
ADD COLUMN `name_en` VARCHAR(180) NULL DEFAULT NULL AFTER `name`;

ALTER TABLE `continent` 
ADD COLUMN `name_en` VARCHAR(100) NULL DEFAULT NULL AFTER `name`;
UPDATE `continent` SET `name_en` = 'Asia' WHERE (`id` = '1');
UPDATE `continent` SET `name_en` = 'Africa' WHERE (`id` = '2');
UPDATE `continent` SET `name_en` = 'America' WHERE (`id` = '3');
UPDATE `continent` SET `name_en` = 'Antarctica' WHERE (`id` = '4');
UPDATE `continent` SET `name_en` = 'Europe' WHERE (`id` = '5');
UPDATE `continent` SET `name_en` = 'Oceania' WHERE (`id` = '6');

ALTER TABLE `country` 
ADD COLUMN `name_en` VARCHAR(45) NULL DEFAULT NULL AFTER `name`;
ALTER TABLE `country` 
ADD COLUMN `slug_en` VARCHAR(50) NULL DEFAULT NULL AFTER `slug`;


ALTER TABLE `region` 
ADD COLUMN `name_en` VARCHAR(150) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `abbreviation_en` VARCHAR(20) NULL AFTER `abbreviation`,
ADD COLUMN `slug_en` VARCHAR(180) NULL DEFAULT NULL AFTER `slug`;

ALTER TABLE `city` 
ADD COLUMN `name_en` VARCHAR(180) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `slug_en` VARCHAR(180) NULL DEFAULT NULL AFTER `slug`;

ALTER TABLE `subcategories` 
ADD COLUMN `name_en` VARCHAR(150) NULL DEFAULT NULL AFTER `name`;

ALTER TABLE `icons` 
ADD COLUMN `name_en` VARCHAR(150) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `type_en` VARCHAR(50) NULL DEFAULT NULL AFTER `type`;

ALTER TABLE `pickups` 
ADD COLUMN `id_en` VARCHAR(50) NULL DEFAULT NULL AFTER `id`,
ADD COLUMN `name_en` VARCHAR(80) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `description_en` VARCHAR(150) NULL DEFAULT NULL AFTER `description`;


ALTER TABLE `tour_pax_type` 
ADD COLUMN `name_en` VARCHAR(100) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `name_plural_en` VARCHAR(100) NULL DEFAULT NULL AFTER `name_plural`;
ALTER TABLE `tour_pax_type` 
DROP FOREIGN KEY `fk_l_0`;
ALTER TABLE `tour_pax_type` 
CHANGE COLUMN `id_language` `id_language` INT NULL ;
ALTER TABLE `tour_pax_type` 
ADD CONSTRAINT `fk_l_0`
  FOREIGN KEY (`id_language`)
  REFERENCES `languages` (`id`);
ALTER TABLE `tour_pax_type` 
CHANGE COLUMN `is_active` `is_active` TINYINT(1) NOT NULL DEFAULT '1' ;

ALTER TABLE `tour_meeting_points` 
ADD COLUMN `pickup_note` VARCHAR(250) NULL DEFAULT NULL AFTER `pickup`;

ALTER TABLE `tour_extra_metting` 
ADD COLUMN `pickup_note` VARCHAR(250) NULL DEFAULT NULL AFTER `id_season`;


ALTER TABLE `tour_details` 
ADD COLUMN `name_en` VARCHAR(180) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `short_description_en` TEXT NULL DEFAULT NULL AFTER `short_description`,
ADD COLUMN `description_en` TEXT NULL DEFAULT NULL AFTER `description`,
ADD COLUMN `itinerary_en` TEXT NULL DEFAULT NULL AFTER `itinerary`,
ADD COLUMN `include_en` TEXT NULL DEFAULT NULL AFTER `include`,
ADD COLUMN `policy_cancellation_en` TEXT NULL DEFAULT NULL AFTER `policy_cancellation`,
ADD COLUMN `restrictions_en` TEXT NULL DEFAULT NULL AFTER `restrictions`,
ADD COLUMN `requirement_en` TEXT NULL DEFAULT NULL AFTER `requirement`,
ADD COLUMN `not_included_en` TEXT NULL DEFAULT NULL AFTER `not_included`,
ADD COLUMN `what_you_need_en` TEXT NULL DEFAULT NULL AFTER `what_you_need`,
ADD COLUMN `slug_en` VARCHAR(180) NULL DEFAULT NULL AFTER `slug`,
ADD COLUMN `instructions_en` TEXT NULL DEFAULT NULL AFTER `instructions`,
ADD COLUMN `additional_information_en` TEXT NULL DEFAULT NULL AFTER `additional_information`,
ADD COLUMN `free_cancellation_en` TEXT NULL DEFAULT NULL AFTER `free_cancellation`;


ALTER TABLE `continent` 
ADD COLUMN `slug_en` VARCHAR(100) NULL DEFAULT NULL AFTER `slug`;


ALTER TABLE `tour_meeting_points` 
ADD COLUMN `pickup_note_en` VARCHAR(250) NULL DEFAULT NULL AFTER `pickup_note`;

ALTER TABLE `tour_itinerary` 
ADD COLUMN `stop_name_en` VARCHAR(280) NULL DEFAULT NULL AFTER `stop_name`,
ADD COLUMN `description_en` VARCHAR(180) NULL DEFAULT NULL AFTER `description`;

ALTER TABLE `tour_duration_type` 
ADD COLUMN `name_en` VARCHAR(150) NULL DEFAULT NULL AFTER `name`,
ADD COLUMN `singular_en` VARCHAR(150) NULL DEFAULT NULL AFTER `singular`;
UPDATE `tour_duration_type` SET `name` = 'minutos', `singular` = 'minuto' WHERE (`id` = '1');
UPDATE `tour_duration_type` SET `name` = 'horas', `singular` = 'hora' WHERE (`id` = '2');
UPDATE `tour_duration_type` SET `name` = 'días', `singular` = 'día' WHERE (`id` = '3');
UPDATE `tour_duration_type` SET `name` = 'semanas', `singular` = 'semana' WHERE (`id` = '4');
UPDATE `tour_duration_type` SET `name` = 'months', `singular` = 'mes' WHERE (`id` = '5');

UPDATE `tour_duration_type` SET `name_en` = 'minutes', `singular_en` = 'minute' WHERE (`id` = '1');
UPDATE `tour_duration_type` SET `name_en` = 'hours', `singular_en` = 'hour' WHERE (`id` = '2');
UPDATE `tour_duration_type` SET `name_en` = 'days', `singular_en` = 'day' WHERE (`id` = '3');
UPDATE `tour_duration_type` SET `name_en` = 'weeks', `singular_en` = 'week' WHERE (`id` = '4');
UPDATE `tour_duration_type` SET `name_en` = 'months', `singular_en` = 'mes' WHERE (`id` = '5');


ALTER TABLE `tour_images` 
ADD COLUMN `caption_en` VARCHAR(350) NULL DEFAULT NULL AFTER `caption`;


ALTER TABLE `tour_details` 
ADD COLUMN `keywords_en` VARCHAR(250) NULL DEFAULT NULL AFTER `keywords`;

ALTER TABLE `tour_extra_attractions` 
ADD COLUMN `attraction_name_en` VARCHAR(150) NULL DEFAULT NULL AFTER `attraction_name`,
ADD COLUMN `description_en` VARCHAR(250) NULL DEFAULT NULL AFTER `description`;

ALTER TABLE `tour_extra_food` 
ADD COLUMN `description_en` VARCHAR(150) NULL DEFAULT NULL AFTER `description`;

UPDATE `tour_optional_extra` SET `name` = 'Punto de encuentro' WHERE (`id` = '8');

ALTER TABLE `tour_extra_custom` 
ADD COLUMN `name_en` VARCHAR(250) NULL DEFAULT NULL AFTER `name`;

ALTER TABLE `tour_season` 
ADD COLUMN `name_en` VARCHAR(180) NULL DEFAULT NULL AFTER `name`;

ALTER TABLE `tour_extra_metting` 
ADD COLUMN `pickup_note_en` VARCHAR(250) NULL DEFAULT NULL AFTER `pickup_note`;

ALTER TABLE `destination_guides` 
ADD COLUMN `title_en` VARCHAR(150) NULL DEFAULT NULL AFTER `title`,
CHANGE COLUMN `title` `title` VARCHAR(150) NULL DEFAULT NULL ;

ALTER TABLE `destination_guides_images` 
ADD COLUMN `caption_en` VARCHAR(350) NULL DEFAULT NULL AFTER `caption`;

ALTER TABLE `destination_guides_section` 
ADD COLUMN `htmlcontent_en` LONGTEXT NULL DEFAULT NULL AFTER `htmlcontent`,
ADD COLUMN `title_en` VARCHAR(150) NULL AFTER `title`,
ADD COLUMN `section_name_en` VARCHAR(80) NULL DEFAULT NULL AFTER `section_name`,
ADD COLUMN `section_en` VARCHAR(45) NULL DEFAULT NULL AFTER `section`;

ALTER TABLE `destination_guides_seo` 
ADD COLUMN `keywords_en` VARCHAR(250) NULL DEFAULT NULL AFTER `id_destination_guides_section`,
ADD COLUMN `description_en` VARCHAR(250) NULL DEFAULT NULL AFTER `keywords_en`,
ADD COLUMN `slug_en` VARCHAR(250) NULL DEFAULT NULL AFTER `description_en`;


UPDATE destination_guides_section SET section_name_en = 'Main Information', section_en = 'main-information' WHERE section = 'informacion-principal-de';
UPDATE destination_guides_section SET section_name_en = 'What to See', section_en = 'what-to-see' WHERE section = 'que-ver-en';
UPDATE destination_guides_section SET section_name_en = 'Attractions', section_en = 'attractions' WHERE section = 'atracciones-en';
UPDATE destination_guides_section SET section_name_en = 'Before Traveling', section_en = 'before-traveling' WHERE section = 'antes-de-viajar-a';
UPDATE destination_guides_section SET section_name_en = 'Where to Stay', section_en = 'where-to-stay' WHERE section = 'donde-dormir-en';
UPDATE destination_guides_section SET section_name_en = 'Gastronomy', section_en = 'gastronomy' WHERE section = 'gastronomia-de';

UPDATE destination_guides_seo dgs
INNER JOIN destination_guides_section dgc on dgc.id = dgs.id_destination_guides_section
INNER JOIN destination_guides dg on dg.id = dgc.id_destination_guides
INNER JOIN city c on c.id = dg.id_city
SET dgs.slug_en = (SELECT CONCAT('main-information-', c.slug_en)) WHERE dgc.section = 'informacion-principal-de';

UPDATE destination_guides_seo dgs
INNER JOIN destination_guides_section dgc on dgc.id = dgs.id_destination_guides_section
INNER JOIN destination_guides dg on dg.id = dgc.id_destination_guides
INNER JOIN city c on c.id = dg.id_city
SET dgs.slug_en = (SELECT CONCAT('what-to-see-', c.slug_en)) WHERE dgc.section = 'que-ver-en';

UPDATE destination_guides_seo dgs
INNER JOIN destination_guides_section dgc on dgc.id = dgs.id_destination_guides_section
INNER JOIN destination_guides dg on dg.id = dgc.id_destination_guides
INNER JOIN city c on c.id = dg.id_city
SET dgs.slug_en = (SELECT CONCAT('attractions-', c.slug_en)) WHERE dgc.section = 'atracciones-en';

UPDATE destination_guides_seo dgs
INNER JOIN destination_guides_section dgc on dgc.id = dgs.id_destination_guides_section
INNER JOIN destination_guides dg on dg.id = dgc.id_destination_guides
INNER JOIN city c on c.id = dg.id_city
SET dgs.slug_en = (SELECT CONCAT('before-traveling-', c.slug_en)) WHERE dgc.section = 'antes-de-viajar-a';

UPDATE destination_guides_seo dgs
INNER JOIN destination_guides_section dgc on dgc.id = dgs.id_destination_guides_section
INNER JOIN destination_guides dg on dg.id = dgc.id_destination_guides
INNER JOIN city c on c.id = dg.id_city
SET dgs.slug_en = (SELECT CONCAT('where-to-stay-', c.slug_en)) WHERE dgc.section = 'donde-dormir-en';

UPDATE destination_guides_seo dgs
INNER JOIN destination_guides_section dgc on dgc.id = dgs.id_destination_guides_section
INNER JOIN destination_guides dg on dg.id = dgc.id_destination_guides
INNER JOIN city c on c.id = dg.id_city
SET dgs.slug_en = (SELECT CONCAT('gastronomy-', c.slug_en)) WHERE dgc.section = 'gastronomia-de';

UPDATE destination_guides dg
INNER JOIN city c on c.id = dg.id_city
SET dg.title_en = (SELECT CONCAT(c.name_en, ' ', 'Guide')) ;

ALTER TABLE `tour_extra_equipment` 
ADD COLUMN `item_name_en` VARCHAR(250) NULL DEFAULT NULL AFTER `item_name`;

ALTER TABLE `attractions` 
ADD COLUMN `title_en` VARCHAR(150) NULL DEFAULT NULL AFTER `title`,
CHANGE COLUMN `title` `title` VARCHAR(150) NULL DEFAULT NULL ;

ALTER TABLE `attractions_images` 
ADD COLUMN `caption_en` VARCHAR(150) NULL DEFAULT NULL AFTER `caption`;

ALTER TABLE `attractions_section` 
ADD COLUMN `htmlcontent_en` LONGTEXT NULL DEFAULT NULL AFTER `htmlcontent`,
ADD COLUMN `title_en` VARCHAR(150) NULL DEFAULT NULL AFTER `title`,
ADD COLUMN `section_name_en` VARCHAR(80) NULL DEFAULT NULL AFTER `section_name`,
ADD COLUMN `section_en` VARCHAR(45) NULL DEFAULT NULL AFTER `section`;

ALTER TABLE `attractions_seo` 
ADD COLUMN `keywords_en` VARCHAR(250) NULL DEFAULT NULL AFTER `keywords`,
ADD COLUMN `description_en` VARCHAR(250) NULL DEFAULT NULL AFTER `description`,
ADD COLUMN `slug_en` VARCHAR(200) NULL DEFAULT NULL AFTER `slug`;

ALTER TABLE `city_summary` 
ADD COLUMN `title_en` VARCHAR(150) NULL DEFAULT NULL AFTER `title`,
ADD COLUMN `short_description_en` VARCHAR(255) NULL DEFAULT NULL AFTER `short_description`,
CHANGE COLUMN `title` `title` VARCHAR(150) NULL DEFAULT NULL ;

ALTER TABLE `city_summary_images` 
ADD COLUMN `caption_en` VARCHAR(150) NULL DEFAULT NULL AFTER `caption`;

ALTER TABLE `city_summary_section` 
ADD COLUMN `htmlcontent_en` TEXT NULL DEFAULT NULL AFTER `htmlcontent`,
ADD COLUMN `section_en` VARCHAR(45) NULL DEFAULT NULL AFTER `section`;


ALTER TABLE city_summary MODIFY COLUMN short_description VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE city_summary MODIFY COLUMN short_description_en VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER TABLE country_summary MODIFY COLUMN short_description VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE country_summary MODIFY COLUMN short_description_en VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER TABLE `city_summary` 
CHANGE COLUMN `title` `title` VARCHAR(150) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ,
CHANGE COLUMN `title_en` `title_en` VARCHAR(150) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ;

ALTER TABLE `country_summary` 
CHARACTER SET = utf8mb4 ;

ALTER TABLE `country_summary_section` 
CHARACTER SET = utf8mb4 ;

ALTER TABLE `country_summary` 
CHANGE COLUMN `title` `title` VARCHAR(150) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ,
CHANGE COLUMN `title_en` `title_en` VARCHAR(150) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ;

ALTER TABLE `country_summary_section` 
CHANGE COLUMN `htmlcontent` `htmlcontent` TEXT CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ,
CHANGE COLUMN `htmlcontent_en` `htmlcontent_en` MEDIUMTEXT CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ;

ALTER TABLE `city_summary_section` 
CHANGE COLUMN `htmlcontent` `htmlcontent` TEXT CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ,
CHANGE COLUMN `htmlcontent_en` `htmlcontent_en` TEXT CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ;

ALTER TABLE `city_summary_section` 
CHARACTER SET = utf8mb4 ;

ALTER TABLE `tour_extra_attractions_tickets` 
ADD COLUMN `ticket_type_en` VARCHAR(80) NULL DEFAULT NULL AFTER `ticket_type`;

ALTER TABLE `tour_extra_food` 
CHANGE COLUMN `description` `description` VARCHAR(350) NULL DEFAULT NULL ,
CHANGE COLUMN `description_en` `description_en` VARCHAR(350) NULL DEFAULT NULL ;

CREATE TABLE tax_types (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50),
    rate DECIMAL(5,2),
    description TEXT
);
INSERT INTO `tax_types` (`name`, `rate`, `description`) VALUES ('IVA', '21%', 'IVA Europeo');

ALTER TABLE city
ADD COLUMN id_tax_type INT,
ADD FOREIGN KEY (id_tax_type) REFERENCES tax_types(id);

UPDATE city
SET id_tax_type = 1
WHERE id IN (
    SELECT city_ids.id
    FROM (
        SELECT city.id AS id
        FROM city
        JOIN region ON city.id_region = region.id
        JOIN country ON region.id_country = country.id
        WHERE 
            (
                country.name LIKE 'Alemania%' OR
                country.name LIKE 'Austria%' OR
                country.name LIKE 'Bélgica%' OR
                country.name LIKE 'Bulgaria%' OR
                country.name LIKE 'Chipre%' OR
                country.name LIKE 'Croacia%' OR
                country.name LIKE 'Dinamarca%' OR
                country.name LIKE 'Eslovaquia%' OR
                country.name LIKE 'Eslovenia%' OR
                country.name LIKE 'España%' OR
                country.name LIKE 'Estonia%' OR
                country.name LIKE 'Finlandia%' OR
                country.name LIKE 'Francia%' OR
                country.name LIKE 'Grecia%' OR
                country.name LIKE 'Hungría%' OR
                country.name LIKE 'Irlanda%' OR
                country.name LIKE 'Italia%' OR
                country.name LIKE 'Letonia%' OR
                country.name LIKE 'Lituania%' OR
                country.name LIKE 'Luxemburgo%' OR
                country.name LIKE 'Malta%' OR
                country.name LIKE 'Países Bajos%' OR
                country.name LIKE 'Polonia%' OR
                country.name LIKE 'Portugal%' OR
                country.name LIKE 'República Checa%' OR
                country.name LIKE 'Rumanía%' OR
                country.name LIKE 'Suecia%'
            )
            OR
            (
                country.name_en LIKE 'Alemania%' OR
                country.name_en LIKE 'Austria%' OR
                country.name_en LIKE 'Bélgica%' OR
                country.name_en LIKE 'Bulgaria%' OR
                country.name_en LIKE 'Chipre%' OR
                country.name_en LIKE 'Croacia%' OR
                country.name_en LIKE 'Dinamarca%' OR
                country.name_en LIKE 'Eslovaquia%' OR
                country.name_en LIKE 'Eslovenia%' OR
                country.name_en LIKE 'España%' OR
                country.name_en LIKE 'Estonia%' OR
                country.name_en LIKE 'Finlandia%' OR
                country.name_en LIKE 'Francia%' OR
                country.name_en LIKE 'Grecia%' OR
                country.name_en LIKE 'Hungría%' OR
                country.name_en LIKE 'Irlanda%' OR
                country.name_en LIKE 'Italia%' OR
                country.name_en LIKE 'Letonia%' OR
                country.name_en LIKE 'Lituania%' OR
                country.name_en LIKE 'Luxemburgo%' OR
                country.name_en LIKE 'Malta%' OR
                country.name_en LIKE 'Países Bajos%' OR
                country.name_en LIKE 'Polonia%' OR
                country.name_en LIKE 'Portugal%' OR
                country.name_en LIKE 'República Checa%' OR
                country.name_en LIKE 'Rumanía%' OR
                country.name_en LIKE 'Suecia%'
            )
    ) AS city_ids
);


ALTER TABLE `tour_itinerary` 
CHANGE COLUMN `description` `description` VARCHAR(512) NULL DEFAULT NULL ,
CHANGE COLUMN `description_en` `description_en` VARCHAR(512) NULL DEFAULT NULL ;

ALTER TABLE country
ADD COLUMN id_tax_type INT,
ADD FOREIGN KEY (id_tax_type) REFERENCES tax_types(id);


CREATE TABLE `tour_rates_range_group` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_tour_rates` int unsigned NOT NULL,
  `num_paxes_min` int NOT NULL,
  `num_paxes_max` int NOT NULL,
  `price` varchar(50) DEFAULT NULL,
  `id_currency` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_trrg_0` (`id_tour_rates`),
  CONSTRAINT `fk_trrg_0` FOREIGN KEY (`id_tour_rates`) REFERENCES `tour_rates` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



ALTER TABLE `tour_booking_rates` 
ADD COLUMN `tax` VARCHAR(180) NULL DEFAULT NULL AFTER `unpaid`;


ALTER TABLE `travel_companion` 
ADD COLUMN `name_en` VARCHAR(50) NULL DEFAULT NULL AFTER `name`,
CHANGE COLUMN `name` `name` VARCHAR(50) NOT NULL ;


# 1) Ir al proyecto
cd c:\xampp\htdocs\backend

# 2) Ver migraciones pendientes (solo tu carpeta de migraciones nuevas)
php yii migrate/new --migrationPath=@app/migrations

# 3) Ejecutarlas
php yii migrate/up --migrationPath=@app/migrations --interactive=0

# 4) Verificar las últimas aplicadas
php yii migrate/history 20 --migrationPath=@app/migrations



CREATE TABLE `tour_booking_meeting_point` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lat` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `lon` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `address` varchar(250) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `id_tour_booking` int NOT NULL DEFAULT '0',
  `mode` enum('meeting_point','hotel_pickup') NOT NULL,
  `pickup` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pickup_note` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pickup_note_en` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_tbmp_booking` (`id_tour_booking`),
  CONSTRAINT `fk_tbmp_booking` FOREIGN KEY (`id_tour_booking`) REFERENCES `tour_booking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


ALTER TABLE `company` 
ADD COLUMN `phone_contact` VARCHAR(45) NULL DEFAULT NULL AFTER `address`;
