CREATE TABLE IF NOT EXISTS `sml_users` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `username` text,
  `email` varchar(191) DEFAULT NULL,
  `password` blob,
  `forgot_code` text,
  `hash` text,
  `role` varchar(50) DEFAULT 'customer',
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `language` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO `sml_users` (`id`, `username`, `password`, `role`) VALUES(1, '<USER_NAME>', <PASSWORD>, 'administrator');

CREATE TABLE IF NOT EXISTS `sml_maps` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_user` int(11) unsigned NOT NULL,
  `date_created` date NOT NULL,
  `name` text,
  `code` text,
  `logo` text,
  `logo_mobile` text,
  `logo_height` smallint(5) DEFAULT '40',
  `logo_height_mobile` smallint(5) DEFAULT '30',
  `logo_link` text,
  `main_color_hex` varchar(7) NOT NULL DEFAULT '#d15f00',
  `markers_size` float NOT NULL DEFAULT '1.1',
  `markers_color_hex` varchar(20) NOT NULL DEFAULT '',
  `markers_icon_color_hex` varchar(7) NOT NULL DEFAULT '#ffffff',
  `markers_color_hex_hover` varchar(20) NOT NULL DEFAULT '',
  `markers_icon_color_hex_hover` varchar(20) NOT NULL DEFAULT '',
  `markers_icon` text,
  `markers_id_icon_library` bigint(20) unsigned NOT NULL DEFAULT 0,
  `pin_marker_size` float NOT NULL DEFAULT '1.1',
  `pin_marker_color_hex` varchar(7) NOT NULL DEFAULT '#ff0000',
  `pin_marker_icon_color_hex` varchar(7) NOT NULL DEFAULT '#ffffff',
  `pin_marker_icon` varchar(50) DEFAULT 'fas fa-map-marker-alt|f3c5',
  `pin_marker_id_icon_library` bigint(20) unsigned NOT NULL DEFAULT 0,
  `pin_marker_align` enum('bottom','middle','top') DEFAULT 'middle',
  `pin_marker_enable` tinyint(1) NOT NULL DEFAULT '0',
  `map_style` varchar(50) NOT NULL DEFAULT 'osm_free',
  `map_style_satellite` varchar(50) NOT NULL DEFAULT 'arcgis',
  `map_type` enum('default','large') DEFAULT 'default',
  `maptiler_api` text,
  `maptiler_api_satellite` text,
  `here_api` text,
  `here_api_satellite` text,
  `here_lang` text,
  `here_lang_satellite` text,
  `google_api` text,
  `google_api_satellite` text,
  `google_lang` text,
  `google_lang_satellite` text,
  `ga_tracking_id` text,
  `friendly_url` text,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `enable_list` tinyint(1) NOT NULL DEFAULT '1',
  `show_list` tinyint(1) NOT NULL DEFAULT '0',
  `limit_list` smallint(5) NOT NULL DEFAULT '-1',
  `enable_search` tinyint(1) NOT NULL DEFAULT '1',
  `enable_search_location` tinyint(1) NOT NULL DEFAULT '0',
  `enable_categories` tinyint(1) NOT NULL DEFAULT '1',
  `show_categories_marker` tinyint(1) NOT NULL DEFAULT '1',
  `fit_categories` tinyint(1) NOT NULL DEFAULT '1',
  `no_category_sel_mode` tinyint(1) NOT NULL DEFAULT '0',
  `category_featured_mode` enum('filter','toggle') DEFAULT 'filter',
  `enable_story` tinyint(1) NOT NULL DEFAULT '1',
  `default_zoom` smallint(5) NOT NULL DEFAULT '0',
  `selected_zoom` smallint(5) NOT NULL DEFAULT '18',
  `duration_zoom` smallint(5) NOT NULL DEFAULT '300',
  `marker_sel_zoom` float NOT NULL DEFAULT '1.5',
  `search_highlight` smallint(5) NOT NULL DEFAULT '-1',
  `my_location_mode` enum('disabled','geolocate','geolocate_follow','follow_geolocate','follow') DEFAULT 'geolocate',
  `my_location_zoom` smallint(5) NOT NULL DEFAULT '0',
  `my_location_follow` smallint(5) NOT NULL DEFAULT '0',
  `default_my_location` tinyint(1) NOT NULL DEFAULT '0',
  `density_color` tinyint(1) NOT NULL DEFAULT '0',
  `density_color_tolerance` smallint(5) NOT NULL DEFAULT '1',
  `password` text,
  `enable_reviews` tinyint(1) NOT NULL DEFAULT '1',
  `enable_add_photo` tinyint(1) NOT NULL DEFAULT '0',
  `viewer_auth_mode` tinyint(1) NOT NULL DEFAULT '0',
  `add_marker_require_login` tinyint(1) NOT NULL DEFAULT '0',
  `review_require_login` tinyint(1) NOT NULL DEFAULT '0',
  `add_photo_require_login` tinyint(1) NOT NULL DEFAULT '0',
  `issue_report_require_login` tinyint(1) NOT NULL DEFAULT '0',
  `live_tracking_require_login` tinyint(1) NOT NULL DEFAULT '0',
  `enable_directions` tinyint(1) NOT NULL DEFAULT '1',
  `enable_popup_directions` tinyint(1) NOT NULL DEFAULT '1',
  `enable_streetview` tinyint(1) NOT NULL DEFAULT '1',
  `enable_share` tinyint(1) NOT NULL DEFAULT '1',
  `enable_share_map` tinyint(1) NOT NULL DEFAULT '1',
  `enable_issue_reports` tinyint(1) NOT NULL DEFAULT '1',
  `enable_last_update` tinyint(1) NOT NULL DEFAULT '0',
  `language` text,
  `languages_enabled` text,
  `street_basemap` text,
  `street_attributions` text,
  `use_street_attributions` tinyint(1) NOT NULL DEFAULT '1',
  `street_basemap_overlay` text,
  `street_overlay_opacity` float NOT NULL DEFAULT 1,
  `satellite_basemap` text,
  `satellite_attributions` text,
  `use_satellite_attributions` tinyint(1) NOT NULL DEFAULT '1',
  `satellite_basemap_overlay` text,
  `satellite_overlay_opacity` float NOT NULL DEFAULT 1,
  `street_maxzoom` int(2) NOT NULL DEFAULT 20,
  `street_minzoom` int(2) NOT NULL DEFAULT 1,
  `satellite_maxzoom` int(2) NOT NULL DEFAULT 20,
  `satellite_minzoom` int(2) NOT NULL DEFAULT 1,
  `enable_map_street` tinyint(1) NOT NULL DEFAULT '1',
  `enable_map_satellite` tinyint(1) NOT NULL DEFAULT '1',
  `map_street_provider` enum('default','openfreemap','carto','stadia','maptiler','here','google','custom') DEFAULT 'default',
  `map_satellite_provider` enum('default','maptiler','here','google','custom') DEFAULT 'default',
  `openfreemap_street_url` text,
  `cluster_distance` smallint(5) NOT NULL DEFAULT '25',
  `cluster_animation` smallint(5) NOT NULL DEFAULT '300',
  `cat_filter` tinyint(1) NOT NULL DEFAULT '0',
  `nav_markers` tinyint(1) NOT NULL DEFAULT '1',
  `enable_add_marker` tinyint(1) NOT NULL DEFAULT '0',
  `font_viewer` varchar(50) DEFAULT 'Roboto',
  `sheet_detail` tinyint(1) NOT NULL DEFAULT '1',
  `default_view` enum('street','satellite') DEFAULT 'street',
  `quality_preset` enum('low', 'medium', 'high', 'custom') DEFAULT 'high',
  `quality_resolution` enum('low', 'medium', 'high') DEFAULT 'high',
  `update_while_animating` tinyint(1) NOT NULL DEFAULT '1',
  `update_while_interacting` tinyint(1) NOT NULL DEFAULT '1',
  `load_tiles_while_animating` tinyint(1) NOT NULL DEFAULT '1',
  `load_tiles_while_interacting` tinyint(1) NOT NULL DEFAULT '1',
  `preload_tiles` smallint(5) NOT NULL DEFAULT '10',
  `render_buffer` smallint(5) NOT NULL DEFAULT '200',
  `order_by` enum('priority','name','city') DEFAULT 'priority',
  `order_by_distance` tinyint(1) NOT NULL DEFAULT '1',
  `show_in_first_page` tinyint(1) NOT NULL DEFAULT '0',
  `weather` enum('celsius','fahrenheit','none') DEFAULT 'celsius',
  `cat_filter_type` enum('or','and','or_and','and_or') DEFAULT 'or',
  `enable_globe` tinyint(1) NOT NULL DEFAULT '0',
  `meta_title` text,
  `meta_description` text,
  `meta_image` text,
  `draw_geometries` longtext DEFAULT NULL,
  `enable_popup` tinyint(1) NOT NULL DEFAULT '1',
  `popup_image_height` smallint(5) NOT NULL DEFAULT '60',
  `popup_background` varchar(7) NOT NULL DEFAULT '#ffffff',
  `popup_color` varchar(7) NOT NULL DEFAULT '#000000',
  `sheet_mobile` enum('reduced','opened') DEFAULT 'reduced',
  `direction_map` enum('openrouteservice','google','bing','baidu','yandex') DEFAULT 'google',
  `streetview_map` enum('google','bing','yandex') DEFAULT 'google',
  `background_image` text,
  `background_image_mobile` text,
  `auto_start` tinyint(1) NOT NULL DEFAULT '1',
  `loading_visible` tinyint(1) NOT NULL DEFAULT '1',
  `loading_background_color` varchar(7) DEFAULT '#343434',
  `loading_text_color` varchar(7) DEFAULT '#ffffff',
  `search_radius_enabled` tinyint(1) NOT NULL DEFAULT '0',
  `search_radius_m` smallint(5) NOT NULL DEFAULT '10000',
  `default_extra_fields` text DEFAULT NULL,
  `default_am_fields` text DEFAULT NULL,
  `default_am_placeholders` text DEFAULT NULL,
  `add_marker_fields_mandatory` text DEFAULT NULL,
  `add_marker_multiple_category` tinyint(1) NOT NULL DEFAULT '1',
  `default_prefix` text DEFAULT NULL,
  `share_providers` varchar(250) NOT NULL DEFAULT 'copy_link,email,whatsapp,facebook,twitter,linkedin,telegram,facebook_messenger,pinterest,reddit,line,viber,vk,qzone,wechat,threads',
  `enable_intro` tinyint(1) NOT NULL DEFAULT '0',
  `intro_only_direct` tinyint(1) NOT NULL DEFAULT '1',
  `intro_image` text,
  `intro_params` text,
  `cookie_consent` tinyint(1) NOT NULL DEFAULT '0',
  `unit_map` enum('km','miles') DEFAULT 'km',
  `marker_images_num` smallint(5) NOT NULL DEFAULT '-1',
  `marker_images_compression` smallint(5) NOT NULL DEFAULT '90',
  `marker_images_max_size` smallint(5) NOT NULL DEFAULT '3840',
  `info_enable` tinyint(1) NOT NULL DEFAULT '0',
  `info_auto_open` tinyint(1) NOT NULL DEFAULT '0',
  `info_icon` varchar(50) DEFAULT 'fas fa-info',
  `info_content` longtext,
  `song` text,
  `song_link` text,
  `song_bg_volume` float NOT NULL DEFAULT '1.0',
  `song_autoplay` tinyint(1) NOT NULL DEFAULT '1',
  `song_loop` tinyint(1) NOT NULL DEFAULT '1',
  `tts_enable` tinyint(1) NOT NULL DEFAULT '0',
  `extent` text,
  `live_tracking` tinyint(1) NOT NULL DEFAULT '0',
  `live_tracking_interval` smallint(5) NOT NULL DEFAULT '5000',
  `live_tracking_timeout` smallint(5) NOT NULL DEFAULT '10000',
  `live_tracking_only_admin` tinyint(1) NOT NULL DEFAULT '0',
  `custom_html` longtext,
  `pwa_enable` tinyint(1) NOT NULL DEFAULT '1',
  `include_sitemap` tinyint(1) NOT NULL DEFAULT '0',
  `address_format` varchar(250) DEFAULT '[{"field":"street","enabled":true},{"field":"city","enabled":true},{"field":"county","enabled":true},{"field":"state","enabled":true},{"field":"postal_code","enabled":true},{"field":"country","enabled":true}]',
  `add_markers_countries_allowed` longtext,
  `show_legal` tinyint(1) NOT NULL DEFAULT '1',
  `show_scale_control` tinyint(1) NOT NULL DEFAULT '1',
  `enable_measure` tinyint(1) NOT NULL DEFAULT '1',
  `lazy_loading` tinyint(1) NOT NULL DEFAULT '0',
  `lazy_loading_max_markers` smallint(5) NOT NULL DEFAULT '1000',
  `wake_lock` tinyint(1) NOT NULL DEFAULT '2',
  PRIMARY KEY (`id`),
  KEY `id_user` (`id_user`),
  CONSTRAINT `sml_maps_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_maps_lang` (
    `id_map` bigint(20) unsigned DEFAULT NULL,
    `language` varchar(10) DEFAULT NULL,
    `name` text,
    `meta_title` text,
    `meta_description` text,
    `info_content` longtext,
    `intro_params` text,
    `default_am_placeholders` text,
    UNIQUE KEY `id_map` (`id_map`,`language`),
    CONSTRAINT `sml_maps_lang_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_categories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_map` bigint(20) unsigned DEFAULT NULL,
  `name` text,
  `default_selected` tinyint(1) NOT NULL DEFAULT 0,
  `featured` tinyint(1) NOT NULL DEFAULT 0,
  `add_from_map` tinyint(1) NOT NULL DEFAULT 1,
  `id_category_parent` bigint(20) unsigned DEFAULT NULL,
  `markers_size` float NOT NULL DEFAULT '1.1',
  `markers_color_hex` text,
  `markers_icon_color_hex` varchar(7) NOT NULL DEFAULT '#ffffff',
  `markers_color_hex_hover` text,
  `markers_icon_color_hex_hover` text,
  `markers_icon` text,
  `markers_id_icon_library` bigint(20) unsigned NOT NULL DEFAULT 0,
  `icon` text,
  `id_icon_library` bigint(20) unsigned NOT NULL DEFAULT 0,
  `color_hex` varchar(7) NOT NULL DEFAULT '#d3d3d3',
  `icon_color_hex` varchar(7) NOT NULL DEFAULT '#ffffff',
  `order` bigint(20) NOT NULL DEFAULT '0',
  `default_am_fields` text DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_map` (`id_map`),
  KEY `id_category_parent` (`id_category_parent`),
  CONSTRAINT `sml_categories_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sml_categories_ibfk_2` FOREIGN KEY (`id_category_parent`) REFERENCES `sml_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_categories_lang` (
   `id_category` bigint(20) unsigned DEFAULT NULL,
   `language` varchar(10) DEFAULT NULL,
   `name` text,
   UNIQUE KEY `id_category` (`id_category`,`language`),
   CONSTRAINT `sml_categories_lang_ibfk_1` FOREIGN KEY (`id_category`) REFERENCES `sml_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_markers` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_map` bigint(20) unsigned DEFAULT NULL,
  `id_user` int(11) unsigned DEFAULT NULL,
  `update_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `lat` varchar(50),
  `lon` varchar(50),
  `name` varchar(100),
  `type` enum('default','link','link_same','iframe') DEFAULT 'default',
  `link` text,
  `street` text,
  `city` text,
  `county` text,
  `state` text,
  `postal_code` text,
  `country` text,
  `website` text,
  `website_caption` text,
  `email` text,
  `phone` text,
  `whatsapp` text,
  `hours` text,
  `description` text,
  `extra_field_name_1` text DEFAULT NULL,
  `extra_field_value_1` text DEFAULT NULL,
  `extra_field_icon_1` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_2` text DEFAULT NULL,
  `extra_field_value_2` text DEFAULT NULL,
  `extra_field_icon_2` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_3` text DEFAULT NULL,
  `extra_field_value_3` text DEFAULT NULL,
  `extra_field_icon_3` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_4` text DEFAULT NULL,
  `extra_field_value_4` text DEFAULT NULL,
  `extra_field_icon_4` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_5` text DEFAULT NULL,
  `extra_field_value_5` text DEFAULT NULL,
  `extra_field_icon_5` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_6` text DEFAULT NULL,
  `extra_field_value_6` text DEFAULT NULL,
  `extra_field_icon_6` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_7` text DEFAULT NULL,
  `extra_field_value_7` text DEFAULT NULL,
  `extra_field_icon_7` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_8` text DEFAULT NULL,
  `extra_field_value_8` text DEFAULT NULL,
  `extra_field_icon_8` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_9` text DEFAULT NULL,
  `extra_field_value_9` text DEFAULT NULL,
  `extra_field_icon_9` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_10` text DEFAULT NULL,
  `extra_field_value_10` text DEFAULT NULL,
  `extra_field_icon_10` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_11` text DEFAULT NULL,
  `extra_field_value_11` text DEFAULT NULL,
  `extra_field_icon_11` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_12` text DEFAULT NULL,
  `extra_field_value_12` text DEFAULT NULL,
  `extra_field_icon_12` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_13` text DEFAULT NULL,
  `extra_field_value_13` text DEFAULT NULL,
  `extra_field_icon_13` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_14` text DEFAULT NULL,
  `extra_field_value_14` text DEFAULT NULL,
  `extra_field_icon_14` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_15` text DEFAULT NULL,
  `extra_field_value_15` text DEFAULT NULL,
  `extra_field_icon_15` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_16` text DEFAULT NULL,
  `extra_field_value_16` text DEFAULT NULL,
  `extra_field_icon_16` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_17` text DEFAULT NULL,
  `extra_field_value_17` text DEFAULT NULL,
  `extra_field_icon_17` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_18` text DEFAULT NULL,
  `extra_field_value_18` text DEFAULT NULL,
  `extra_field_icon_18` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_19` text DEFAULT NULL,
  `extra_field_value_19` text DEFAULT NULL,
  `extra_field_icon_19` varchar(50) DEFAULT 'far fa-circle',
  `extra_field_name_20` text DEFAULT NULL,
  `extra_field_value_20` text DEFAULT NULL,
  `extra_field_icon_20` varchar(50) DEFAULT 'far fa-circle',
  `extra_button_value_1` text DEFAULT NULL,
  `extra_button_icon_1` varchar(50) DEFAULT 'fas fa-info',
  `extra_button_title_1` text,
  `extra_field_visible_1` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_2` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_3` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_4` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_5` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_6` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_7` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_8` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_9` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_10` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_11` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_12` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_13` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_14` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_15` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_16` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_17` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_18` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_19` tinyint(1) NOT NULL DEFAULT '1',
  `extra_field_visible_20` tinyint(1) NOT NULL DEFAULT '1',
  `open_extra_content` tinyint(1) NOT NULL DEFAULT '0',
  `icon` text,
  `icon_label` text,
  `icon_label_size` smallint(5) NOT NULL DEFAULT 12,
  `icon_label_color` varchar(7) NOT NULL DEFAULT '#000000',
  `id_icon_library` bigint(20) unsigned NOT NULL DEFAULT 0,
  `color_hex` text,
  `icon_color_hex` varchar(7) NOT NULL DEFAULT '#ffffff',
  `color_hex_hover` text,
  `icon_color_hex_hover` text,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `visible_search` tinyint(1) NOT NULL DEFAULT '1',
  `visible_map` tinyint(1) NOT NULL DEFAULT '1',
  `featured` tinyint(1) NOT NULL DEFAULT '0',
  `to_validate` tinyint(1) NOT NULL DEFAULT '0',
  `view_directions` tinyint(1) NOT NULL DEFAULT '1',
  `view_review` tinyint(1) NOT NULL DEFAULT '1',
  `view_add_photo` tinyint(1) NOT NULL DEFAULT '1',
  `view_street_view` tinyint(1) NOT NULL DEFAULT '1',
  `view_share` tinyint(1) NOT NULL DEFAULT '1',
  `view_last_update` tinyint(1) NOT NULL DEFAULT '1',
  `order` bigint(20) NOT NULL DEFAULT '0',
  `centered` tinyint(1) NOT NULL DEFAULT '0',
  `marker_size` float NOT NULL DEFAULT '0',
  `id_category` bigint(20) unsigned DEFAULT NULL,
  `access_count` smallint(5) NOT NULL DEFAULT '0',
  `min_zoom_level` smallint(5) NOT NULL DEFAULT '0',
  `geofence_radius` smallint(5) NOT NULL DEFAULT '0',
  `geofence_color` varchar(28) NOT NULL DEFAULT 'rgba(0,0,255,0.1)',
  `open_sheet` tinyint(1) NOT NULL DEFAULT '1',
  `view_popup` tinyint(1) NOT NULL DEFAULT '1',
  `popup_image_height` smallint(5) NOT NULL DEFAULT '60',
  `popup_background` varchar(7) NOT NULL DEFAULT '#ffffff',
  `popup_color` varchar(7) NOT NULL DEFAULT '#000000',
  `schedule` text,
  `box_warning` text,
  `schedule_box_warning` text,
  `song` text,
  `song_link` text,
  `song_bg_volume` float NOT NULL DEFAULT '0.3',
  `song_volume` float NOT NULL DEFAULT '1.0',
  `song_play_bg` tinyint(1) NOT NULL DEFAULT '0',
  `selected_zoom` smallint(5) NOT NULL DEFAULT '-1',
  `duration_zoom` smallint(5) NOT NULL DEFAULT '-1',
  `tripadvisor_location_id` text,
  `tripadvisor_update_date` datetime,
  `tripadvisor_rating` float NOT NULL DEFAULT '0.0',
  `tripadvisor_reviews` smallint(5) NOT NULL DEFAULT '0',
  `tripadvisor_link` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `lat_lon` (`id_map`,`lat`,`lon`,`name`),
  KEY `id_map` (`id_map`),
  KEY `id_user` (`id_user`),
  KEY `id_category` (`id_category`),
  CONSTRAINT `sml_markers_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sml_markers_ibfk_2` FOREIGN KEY (`id_category`) REFERENCES `sml_categories` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
  CONSTRAINT `sml_markers_ibfk_3` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_markers_lang` (
   `id_marker` bigint(20) unsigned DEFAULT NULL,
   `language` varchar(10) DEFAULT NULL,
   `name` text,
   `hours` text,
   `description` text,
   `icon_label` text,
   `extra_field_name_1` text DEFAULT NULL,
   `extra_field_value_1` text DEFAULT NULL,
   `extra_field_name_2` text DEFAULT NULL,
   `extra_field_value_2` text DEFAULT NULL,
   `extra_field_name_3` text DEFAULT NULL,
   `extra_field_value_3` text DEFAULT NULL,
   `extra_field_name_4` text DEFAULT NULL,
   `extra_field_value_4` text DEFAULT NULL,
   `extra_field_name_5` text DEFAULT NULL,
   `extra_field_value_5` text DEFAULT NULL,
   `extra_field_name_6` text DEFAULT NULL,
   `extra_field_value_6` text DEFAULT NULL,
   `extra_field_name_7` text DEFAULT NULL,
   `extra_field_value_7` text DEFAULT NULL,
   `extra_field_name_8` text DEFAULT NULL,
   `extra_field_value_8` text DEFAULT NULL,
   `extra_field_name_9` text DEFAULT NULL,
   `extra_field_value_9` text DEFAULT NULL,
   `extra_field_name_10` text DEFAULT NULL,
   `extra_field_value_10` text DEFAULT NULL,
   `extra_field_name_11` text DEFAULT NULL,
   `extra_field_value_11` text DEFAULT NULL,
   `extra_field_name_12` text DEFAULT NULL,
   `extra_field_value_12` text DEFAULT NULL,
   `extra_field_name_13` text DEFAULT NULL,
   `extra_field_value_13` text DEFAULT NULL,
   `extra_field_name_14` text DEFAULT NULL,
   `extra_field_value_14` text DEFAULT NULL,
   `extra_field_name_15` text DEFAULT NULL,
   `extra_field_value_15` text DEFAULT NULL,
   `extra_field_name_16` text DEFAULT NULL,
   `extra_field_value_16` text DEFAULT NULL,
   `extra_field_name_17` text DEFAULT NULL,
   `extra_field_value_17` text DEFAULT NULL,
   `extra_field_name_18` text DEFAULT NULL,
   `extra_field_value_18` text DEFAULT NULL,
   `extra_field_name_19` text DEFAULT NULL,
   `extra_field_value_19` text DEFAULT NULL,
   `extra_field_name_20` text DEFAULT NULL,
   `extra_field_value_20` text DEFAULT NULL,
   `extra_button_title_1` text DEFAULT NULL,
   `extra_button_value_1` text DEFAULT NULL,
   `box_warning` text,
   UNIQUE KEY `id_marker` (`id_marker`,`language`),
   CONSTRAINT `sml_markers_lang_ibfk_1` FOREIGN KEY (`id_marker`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_images` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_marker` bigint(20) unsigned DEFAULT NULL,
  `id_user` int(11) unsigned DEFAULT NULL,
  `image` text,
  `main` tinyint(1) DEFAULT NULL,
  `exclude` tinyint(1) DEFAULT '0',
  `to_validate` tinyint(1) DEFAULT '0',
  `sender_email` text,
  `sender_name` text,
  `priority` smallint(5) NOT NULL DEFAULT '0',
  `rotate` smallint(5) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `id_marker` (`id_marker`),
  KEY `id_user` (`id_user`),
  CONSTRAINT `sml_images_ibfk_1` FOREIGN KEY (`id_marker`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sml_images_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_access_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_map` bigint(20) unsigned DEFAULT NULL,
  `date_time` datetime DEFAULT NULL,
  `ip` text,
  `country_code` text,
  PRIMARY KEY (`id`),
  KEY `id_map` (`id_map`),
  CONSTRAINT `svt_access_log_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_icons` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_map` bigint(20) unsigned DEFAULT NULL,
  `image` text,
  PRIMARY KEY (`id`),
  KEY `id_map` (`id_map`),
  CONSTRAINT `sml_icon_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_reviews` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `identifier` text,
  `id_marker` bigint(20) unsigned NOT NULL,
  `id_user` int(11) unsigned DEFAULT NULL,
  `create_date` datetime NOT NULL,
  `email` text,
  `name` text,
  `rating` int(1) DEFAULT NULL,
  `comment` text DEFAULT NULL,
  `reply` text DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_marker` (`id_marker`),
  KEY `id_user` (`id_user`),
  UNIQUE KEY `id_marker_user` (`id_marker`,`id_user`),
  CONSTRAINT `sml_reviews_ibfk_1` FOREIGN KEY (`id_marker`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sml_reviews_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_markers_categories_assoc` (
    `id_marker` bigint(20) unsigned NOT NULL,
    `id_category` bigint(20) unsigned NOT NULL,
    UNIQUE KEY `id_marker_2` (`id_marker`,`id_category`),
    KEY `id_marker` (`id_marker`),
    KEY `id_category` (`id_category`),
    CONSTRAINT `sml_markers_categories_assoc_ibfk_1` FOREIGN KEY (`id_marker`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT `sml_markers_categories_assoc_ibfk_2` FOREIGN KEY (`id_category`) REFERENCES `sml_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_settings` (
    `id` int(11) NOT NULL DEFAULT '0',
    `name` varchar(200) DEFAULT 'Simple Map Locator',
    `theme_color` varchar(7) NOT NULL DEFAULT '#0b5394',
    `theme_color_dark` text,
    `dark_mode` tinyint(1) NOT NULL DEFAULT '1',
    `font_backend` varchar(50) DEFAULT 'Nunito',
    `sidebar` enum('gradient','flat') DEFAULT 'gradient',
    `sidebar_color1` text,
    `sidebar_color2` text,
    `sidebar_color1_dark` text,
    `sidebar_color2_dark` text,
    `logo` text,
    `background` text,
    `language` varchar(10) NOT NULL DEFAULT 'en_US',
    `language_domain` varchar(50) NOT NULL DEFAULT 'default',
    `help_url` text,
    `languages_enabled` text,
    `welcome_msg` text,
    `purchase_code` text,
    `license` text,
    `version` text,
    `footer_link_1` text,
    `footer_value_1` text,
    `footer_link_2` text,
    `footer_value_2` text,
    `footer_link_3` text,
    `footer_value_3` text,
    `style_login` tinyint(1) NOT NULL DEFAULT '1',
    `font_provider` enum('systems','google','collabs') DEFAULT 'google',
    `openrouteservice_api_key` text,
    `timezone` text,
    `share_providers` varchar(250) NOT NULL DEFAULT 'copy_link,email,whatsapp,facebook,twitter,linkedin,telegram,facebook_messenger,pinterest,reddit,line,viber,vk,qzone,wechat,threads',
    `terms_and_conditions` longtext,
    `privacy_policy` longtext,
    `cookie_policy` longtext,
    `cookie_consent` tinyint(1) NOT NULL DEFAULT '0',
    `ga_tracking_id` text,
    `furl_blacklist` text,
    `id_map_template` bigint(20) unsigned DEFAULT NULL,
    `geocoding_provider` enum('nominatim','google') DEFAULT 'nominatim',
    `google_api_key` text,
    `tripadvisor_api_key` text,
    `pwa_enable` tinyint(1) NOT NULL DEFAULT '1',
    `deepl_api_key` text,
    `enable_deepl` tinyint(1) NOT NULL DEFAULT '0',
    `smtp_server` text,
    `smtp_auth` tinyint(1) NOT NULL DEFAULT '0',
    `smtp_username` text,
    `smtp_password` text,
    `smtp_secure` enum('none','ssl','tls') DEFAULT 'none',
    `smtp_port` smallint(5) DEFAULT NULL,
    `smtp_from_email` text,
    `smtp_from_name` text,
    `smtp_valid` tinyint(1) NOT NULL DEFAULT '0',
    `notify_email` text,
    `notify_marker_to_validate` tinyint(1) NOT NULL DEFAULT '0',
    `notify_review` tinyint(1) NOT NULL DEFAULT '0',
    `notify_issue_report` tinyint(1) NOT NULL DEFAULT '0',
    `notify_photo_to_validate` tinyint(1) NOT NULL DEFAULT '0',
    `validate_email` tinyint(1) NOT NULL DEFAULT '0',
    `mail_forgot_subject` varchar(250) NOT NULL DEFAULT 'Forgot Password',
    `mail_forgot_body` longtext,
    `mail_activate_subject` varchar(250) NOT NULL DEFAULT 'Activation Account',
    `mail_activate_body` longtext,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO `sml_settings` (`id`,`furl_blacklist`,`mail_forgot_body`,`mail_activate_body`) VALUES(1,'ajax,assets,css,facicons,header,img,js,tmp,vendor','<p>Hi %USER_NAME%,<br>this is your verification code: %VERIFICATION_CODE%</p><p><br></p><p>Please click on this link to change your password:</p><p>%LINK%</p>','<p>Hi %USER_NAME%,<br>thanks for signing up!</p><p><br></p><p>Please click on this link to activate your account:</p><p>%LINK%</p>');

CREATE TABLE IF NOT EXISTS `sml_markers_connects` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `id_marker_source` bigint(20) unsigned NOT NULL,
    `id_marker_dest` bigint(20) unsigned NOT NULL,
    `color` varchar(7) NOT NULL DEFAULT '#ff0000',
    `width` smallint(5) NOT NULL DEFAULT 2,
    `title` text,
    `description` longtext,
    PRIMARY KEY (`id`),
    KEY `id_marker_source` (`id_marker_source`),
    KEY `id_marker_dest` (`id_marker_dest`),
    CONSTRAINT `sml_markers_connects_ibfk_1` FOREIGN KEY (`id_marker_source`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT `sml_markers_connects_ibfk_2` FOREIGN KEY (`id_marker_dest`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_markers_connects_lang` (
    `id_marker_connect` bigint(20) unsigned DEFAULT NULL,
    `language` varchar(10) DEFAULT NULL,
    `title` text,
    `description` longtext,
    UNIQUE KEY `id_marker_connect` (`id_marker_connect`,`language`),
    CONSTRAINT `sml_markers_connects_lang_ibfk_1` FOREIGN KEY (`id_marker_connect`) REFERENCES `sml_markers_connects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_assign_maps` (
    `id_user` int(11) unsigned DEFAULT NULL,
    `id_map` bigint(20) unsigned DEFAULT NULL,
    `edit_map` tinyint(1) NOT NULL DEFAULT 1,
    `create_markers` tinyint(1) NOT NULL DEFAULT 1,
    `edit_markers` tinyint(1) NOT NULL DEFAULT 1,
    `delete_markers` tinyint(1) NOT NULL DEFAULT 0,
    `boundaries` tinyint(1) NOT NULL DEFAULT 1,
    `connections` tinyint(1) NOT NULL DEFAULT 1,
    `geometries` tinyint(1) NOT NULL DEFAULT 1,
    `geoimages` tinyint(1) NOT NULL DEFAULT 1,
    `geodata` tinyint(1) NOT NULL DEFAULT 1,
    `story` tinyint(1) NOT NULL DEFAULT 1,
    `categories` tinyint(1) NOT NULL DEFAULT 1,
    `icons_library` tinyint(1) NOT NULL DEFAULT 1,
    `media_library` tinyint(1) NOT NULL DEFAULT 1,
    `review` tinyint(1) NOT NULL DEFAULT 1,
    `issue_report` tinyint(1) NOT NULL DEFAULT 1,
    `publish` tinyint(1) NOT NULL DEFAULT 1,
    `live_tracking` tinyint(1) NOT NULL DEFAULT 1,
    UNIQUE KEY `id_user` (`id_user`,`id_map`),
    KEY `id_map` (`id_map`),
    CONSTRAINT `sml_assign_maps_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT `sml_assign_maps_ibfk_2` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_story` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `id_map` bigint(20) unsigned DEFAULT NULL,
    `id_marker` bigint(20) unsigned DEFAULT NULL,
    `description` text,
    `zoom` smallint(5) NOT NULL DEFAULT 10,
    `priority` smallint(5) NOT NULL,
    PRIMARY KEY (`id`),
    CONSTRAINT `sml_story_sml_maps_id_fk` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT `sml_story_sml_markers_id_fk` FOREIGN KEY (`id_marker`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_story_lang` (
   `id_story` bigint(20) unsigned DEFAULT NULL,
   `language` varchar(10) DEFAULT NULL,
   `description` text,
   UNIQUE KEY `id_story` (`id_story`,`language`),
   CONSTRAINT `sml_story_lang_ibfk_1` FOREIGN KEY (`id_story`) REFERENCES `sml_story` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_showcases` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   `id_user` int(11) unsigned DEFAULT NULL,
   `code` text,
   `name` text,
   `friendly_url` text,
   `banner` text,
   `logo` text,
   `bg_color` varchar(7) NOT NULL DEFAULT '#EEEEEE',
   `header_html` longtext,
   `footer_html` longtext,
   `meta_title` text,
   `meta_description` text,
   `meta_image` text,
   `show_in_first_page` tinyint(1) NOT NULL DEFAULT '0',
   `sort_settings` text,
   `open_target` enum('self','new') NOT NULL DEFAULT 'self',
   `ga_tracking_id` text,
   `cookie_consent` tinyint(1) NOT NULL DEFAULT '0',
   `language` text,
   `languages_enabled` text,
   `pwa_enable` tinyint(1) NOT NULL DEFAULT '1',
   PRIMARY KEY (`id`),
   KEY `id_user` (`id_user`),
   CONSTRAINT `sml_showcases_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_showcases_lang` (
    `id_showcase` bigint(20) unsigned DEFAULT NULL,
    `language` varchar(10) DEFAULT NULL,
    `name` text,
    `header_html` longtext,
    `footer_html` longtext,
    `meta_title` text,
    `meta_description` text,
    UNIQUE KEY `id_showcase` (`id_showcase`,`language`),
    CONSTRAINT `sml_showcases_lang_ibfk_1` FOREIGN KEY (`id_showcase`) REFERENCES `sml_showcases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_showcase_list` (
   `id_showcase` bigint(20) unsigned DEFAULT NULL,
   `id_map` bigint(20) unsigned DEFAULT NULL,
   `priority` smallint(5) NOT NULL DEFAULT 0,
   KEY `id_showcase` (`id_showcase`),
   KEY `id_map` (`id_map`),
   CONSTRAINT `sml_showcase_list_ibfk_1` FOREIGN KEY (`id_showcase`) REFERENCES `sml_showcases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `sml_showcase_list_ibfk_2` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_geoimages` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `id_map` bigint(20) unsigned DEFAULT NULL,
    `image` text,
    `params` text,
    PRIMARY KEY (`id`),
    KEY `id_map` (`id_map`),
    CONSTRAINT `sml_geoimages_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_geodata` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   `id_map` bigint(20) unsigned DEFAULT NULL,
   `file` text,
   `style` text,
   `content` longtext,
   PRIMARY KEY (`id`),
   KEY `id_map` (`id_map`),
   CONSTRAINT `sml_geodata_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_geodata_lang` (
    `id_geodata` bigint(20) unsigned DEFAULT NULL,
    `language` varchar(10) DEFAULT NULL,
    `content` text,
    UNIQUE KEY `id_geodata` (`id_geodata`,`language`),
    CONSTRAINT `sml_geodata_lang_ibfk_1` FOREIGN KEY (`id_geodata`) REFERENCES `sml_geodata` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_geodata_categories_assoc` (
  `id_geodata` bigint(20) unsigned NOT NULL,
  `id_category` bigint(20) unsigned NOT NULL,
  UNIQUE KEY `id_geodata_2` (`id_geodata`,`id_category`),
  KEY `id_geodata` (`id_geodata`),
  KEY `id_category` (`id_category`),
  CONSTRAINT `sml_geodata_categories_assoc_ibfk_1` FOREIGN KEY (`id_geodata`) REFERENCES `sml_geodata` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sml_geodata_categories_assoc_ibfk_2` FOREIGN KEY (`id_category`) REFERENCES `sml_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_live_tracking` (
 `id` varchar(128),
 `id_map` bigint(20) unsigned DEFAULT NULL,
 `id_user` int(11) unsigned DEFAULT NULL,
 `lat` text,
 `lon` text,
 `name` text,
 `color` text,
 `updated_at` datetime NOT NULL,
 UNIQUE KEY `id_id_map` (`id`,`id_map`),
 KEY `id_map` (`id_map`),
 KEY `id_user` (`id_user`),
 CONSTRAINT `sml_live_tracking_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
 CONSTRAINT `sml_live_tracking_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_live_tracking_history` (
   `id` varchar(128),
   `id_map` bigint(20) unsigned DEFAULT NULL,
   `id_user` int(11) unsigned DEFAULT NULL,
   `lat` double,
   `lon` double,
   `name` text,
   `tracked_at` datetime,
   `updated_at` datetime,
   UNIQUE KEY `id_id_map_lat_lon` (`id`,`id_map`,`lat`,`lon`),
   KEY `id_map` (`id_map`),
   KEY `id_user` (`id_user`),
   CONSTRAINT `sml_live_tracking_history_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `sml_live_tracking_history_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_map_categories` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `name` text,
    `icon` text,
    `background` varchar(7) NOT NULL DEFAULT '#f8f9fa',
    `color` varchar(7) NOT NULL DEFAULT '#000000',
    `position` smallint(5) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_map_categories_lang` (
     `id_map_category` int(11) unsigned DEFAULT NULL,
     `language` varchar(10) DEFAULT NULL,
     `name` text,
     UNIQUE KEY `id_map_category` (`id_map_category`,`language`),
     CONSTRAINT `sml_map_categories_lang_ibfk_1` FOREIGN KEY (`id_map_category`) REFERENCES `sml_map_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_category_map_assoc` (
    `id_map` bigint(20) unsigned DEFAULT NULL,
    `id_category` int(11) unsigned DEFAULT NULL,
    KEY `id_map` (`id_map`),
    KEY `id_category` (`id_category`),
    CONSTRAINT `sml_category_map_assoc_ibfk_1` FOREIGN KEY (`id_category`) REFERENCES `sml_map_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT `sml_category_map_assoc_ibfk_2` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_issue_reports` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
     `id_marker` bigint(20) unsigned NOT NULL,
     `id_user` int(11) unsigned DEFAULT NULL,
     `create_date` datetime NOT NULL,
     `email` text,
     `name` text,
     `comment` text DEFAULT NULL,
     `checked` tinyint(1) NOT NULL DEFAULT '0',
     PRIMARY KEY (`id`),
     KEY `id_marker` (`id_marker`),
     KEY `id_user` (`id_user`),
 CONSTRAINT `sml_issue_reports_ibfk_1` FOREIGN KEY (`id_marker`) REFERENCES `sml_markers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
 CONSTRAINT `sml_issue_reports_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_remember_tokens` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `id_user` int(11) unsigned NOT NULL,
    `selector` char(32) NOT NULL,
    `validator_hash` char(64) NOT NULL,
    `expires_at` datetime NOT NULL,
    `created_at` datetime NOT NULL,
    `last_used_at` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `selector` (`selector`),
    KEY `id_user` (`id_user`),
    KEY `expires_at` (`expires_at`),
    CONSTRAINT `sml_remember_tokens_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `sml_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `sml_media_library` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   `id_map` bigint(20) unsigned DEFAULT NULL,
   `file` text,
   PRIMARY KEY (`id`),
   KEY `id_map` (`id_map`),
   CONSTRAINT `sml_media_library_ibfk_1` FOREIGN KEY (`id_map`) REFERENCES `sml_maps` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
