-- MySQL dump 10.13  Distrib 8.0.42, for Linux (x86_64)
--
-- Host: localhost    Database: forge2
-- ------------------------------------------------------
-- Server version	8.0.42-0ubuntu0.20.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `account_types`
--

DROP TABLE IF EXISTS `account_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `account_types` (
  `account_type_id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`account_type_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `accounts`
--

DROP TABLE IF EXISTS `accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `accounts` (
  `account_id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `account_type_id` int NOT NULL COMMENT 'Tipo',
  `client_id` int NOT NULL COMMENT 'Cliente',
  `username` varchar(255) DEFAULT NULL COMMENT 'Usuario',
  `password` varchar(255) DEFAULT NULL COMMENT 'Contraseña',
  `token` text,
  `refresh_token` text,
  `token_expiration` datetime DEFAULT NULL,
  `active` int NOT NULL DEFAULT '1' COMMENT 'Activo',
  `user_id` int NOT NULL DEFAULT '1' COMMENT 'Usuario',
  `date` datetime DEFAULT NULL COMMENT 'Fecha Actualización',
  `created` datetime DEFAULT NULL COMMENT 'Fecha Creación',
  PRIMARY KEY (`account_id`) USING BTREE,
  KEY `account_type_id` (`account_type_id`) USING BTREE,
  KEY `client_id` (`client_id`) USING BTREE,
  KEY `account_ibfk_3_idx` (`user_id`) USING BTREE,
  CONSTRAINT `account_ibfk_1` FOREIGN KEY (`account_type_id`) REFERENCES `account_types` (`account_type_id`),
  CONSTRAINT `account_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`),
  CONSTRAINT `account_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `action_types`
--

DROP TABLE IF EXISTS `action_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `action_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(256) COLLATE utf8mb4_general_ci NOT NULL,
  `description` varchar(256) COLLATE utf8mb4_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarm_cameras`
--

DROP TABLE IF EXISTS `alarm_cameras`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarm_cameras` (
  `imei` varchar(20) NOT NULL,
  `camera_id` int NOT NULL,
  KEY `imei` (`imei`) USING BTREE,
  KEY `camera_id` (`camera_id`) USING BTREE,
  CONSTRAINT `alarm_camera_ibfk_1` FOREIGN KEY (`imei`) REFERENCES `alarms` (`imei`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `alarm_camera_ibfk_2` FOREIGN KEY (`camera_id`) REFERENCES `cameras` (`camera_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarm_events`
--

DROP TABLE IF EXISTS `alarm_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarm_events` (
  `alarm_event_id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`alarm_event_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarm_logs`
--

DROP TABLE IF EXISTS `alarm_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarm_logs` (
  `alarm_log_id` int NOT NULL AUTO_INCREMENT,
  `imei` varchar(20) NOT NULL,
  `alarm_event_id` int NOT NULL,
  `alarm_person_id` int DEFAULT '12',
  `area` varchar(10) DEFAULT NULL COMMENT 'Zona',
  `status` int NOT NULL DEFAULT '0' COMMENT 'Estado',
  `user_id` int DEFAULT NULL COMMENT 'Usuario que atiende',
  `observations` text,
  `created` datetime DEFAULT NULL COMMENT 'Fecha Creación',
  `date` datetime DEFAULT NULL COMMENT 'Fecha Actualización',
  `image_url` longblob,
  `video_url` text,
  `download` int NOT NULL DEFAULT '0' COMMENT 'Tipo de Descarga:\n0: No permitido para descarga de video\n1: Con permiso para descarga de video\n2: Con video ya descargado',
  `alarm_type_id` int DEFAULT NULL,
  PRIMARY KEY (`alarm_log_id`) USING BTREE,
  KEY `imei` (`imei`) USING BTREE,
  KEY `alarm_log_ibfk_3` (`alarm_event_id`) USING BTREE,
  KEY `alarm_log_ibfk_4_idx` (`user_id`) USING BTREE,
  KEY `alarm_log_ibfk_5_idx` (`alarm_type_id`) USING BTREE,
  KEY `alarm_log_ibfk_6_idx` (`alarm_person_id`) USING BTREE,
  KEY `index_alarm_log_date` (`date`) USING BTREE,
  KEY `index_alarm_log_created` (`created`) USING BTREE,
  CONSTRAINT `alarm_log_ibfk_1` FOREIGN KEY (`imei`) REFERENCES `alarms` (`imei`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `alarm_log_ibfk_3` FOREIGN KEY (`alarm_event_id`) REFERENCES `alarm_events` (`alarm_event_id`) ON DELETE CASCADE,
  CONSTRAINT `alarm_log_ibfk_4` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
  CONSTRAINT `alarm_log_ibfk_5` FOREIGN KEY (`alarm_type_id`) REFERENCES `alarm_types` (`alarm_type_id`),
  CONSTRAINT `alarm_log_ibfk_6` FOREIGN KEY (`alarm_person_id`) REFERENCES `alarm_persons` (`alarm_person_id`)
) ENGINE=InnoDB AUTO_INCREMENT=74455 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarm_modes`
--

DROP TABLE IF EXISTS `alarm_modes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarm_modes` (
  `alarm_mode_id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`alarm_mode_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarm_persons`
--

DROP TABLE IF EXISTS `alarm_persons`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarm_persons` (
  `alarm_person_id` int NOT NULL AUTO_INCREMENT,
  `imei` varchar(20) DEFAULT NULL,
  `name` varchar(32) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `date` datetime DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `document_url` mediumtext CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci,
  `active` int DEFAULT '1',
  `user_id` int DEFAULT '1',
  `state_id` int DEFAULT NULL,
  `city_id` int DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `cuadrante` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`alarm_person_id`) USING BTREE,
  KEY `imei` (`imei`) USING BTREE,
  KEY `alarm_person_ibfk_2` (`user_id`) USING BTREE,
  CONSTRAINT `alarm_person_ibfk_1` FOREIGN KEY (`imei`) REFERENCES `alarms` (`imei`),
  CONSTRAINT `alarm_person_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1129 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarm_types`
--

DROP TABLE IF EXISTS `alarm_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarm_types` (
  `alarm_type_id` int NOT NULL AUTO_INCREMENT,
  `type` varchar(45) DEFAULT NULL,
  `active` int DEFAULT '1',
  PRIMARY KEY (`alarm_type_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `alarms`
--

DROP TABLE IF EXISTS `alarms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alarms` (
  `imei` varchar(20) NOT NULL COMMENT 'IMEI',
  `alarm_mode_id` int DEFAULT NULL COMMENT 'Tipo',
  `client_id` int NOT NULL COMMENT 'Cliente',
  `name` varchar(50) DEFAULT NULL COMMENT 'Nombre',
  `address` varchar(100) DEFAULT NULL COMMENT 'Dirección',
  `district_id` int DEFAULT NULL COMMENT 'Localidad / Comuna',
  `neighborhood` varchar(150) DEFAULT NULL COMMENT 'Barrio',
  `legacy_city_id` varchar(6) NOT NULL COMMENT 'Ciudad',
  `latitude` decimal(18,15) DEFAULT NULL COMMENT 'Latitud',
  `longitude` decimal(18,15) DEFAULT NULL COMMENT 'Longitud',
  `mobile_operator_id` int NOT NULL COMMENT 'Operador',
  `phone` varchar(20) NOT NULL COMMENT 'Celular panel de alarma',
  `active` int NOT NULL DEFAULT '1' COMMENT 'Activo',
  `status` tinyint DEFAULT NULL COMMENT 'Estado',
  `created` datetime DEFAULT NULL,
  `user_id` int NOT NULL DEFAULT '1',
  `date` datetime DEFAULT NULL COMMENT 'Fecha actualización',
  `city_id` int unsigned DEFAULT NULL,
  PRIMARY KEY (`imei`) USING BTREE,
  KEY `city_id` (`legacy_city_id`) USING BTREE,
  KEY `district_id` (`district_id`) USING BTREE,
  KEY `mobile_operator_id` (`mobile_operator_id`) USING BTREE,
  KEY `client_id` (`client_id`) USING BTREE,
  KEY `alarm_ibfk_5_idx` (`user_id`) USING BTREE,
  KEY `alarm_mode_id` (`alarm_mode_id`) USING BTREE,
  KEY `fk_alarms_city_id` (`city_id`),
  CONSTRAINT `alarm_ibfk_2` FOREIGN KEY (`district_id`) REFERENCES `districts` (`district_id`),
  CONSTRAINT `alarm_ibfk_3` FOREIGN KEY (`mobile_operator_id`) REFERENCES `mobile_operators` (`mobile_operator_id`),
  CONSTRAINT `alarm_ibfk_4` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`),
  CONSTRAINT `alarm_ibfk_5` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
  CONSTRAINT `alarm_ibfk_6` FOREIGN KEY (`alarm_mode_id`) REFERENCES `alarm_modes` (`alarm_mode_id`),
  CONSTRAINT `fk_alarms_city_id` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `audit_logs`
--

DROP TABLE IF EXISTS `audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `audit_logs` (
  `audit_log_id` int NOT NULL AUTO_INCREMENT,
  `module_id` int NOT NULL,
  `module` varchar(45) DEFAULT NULL,
  `action` int NOT NULL COMMENT 'Valores para los registros:\n1. Registros Agregados.\n2. Registros Actualizados.\n3. Registros Borrados/Eliminados',
  `action_name` varchar(45) DEFAULT NULL,
  `user_id` int NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `client_id` int DEFAULT NULL,
  `integrator_id` int DEFAULT NULL,
  `date` datetime NOT NULL,
  `option_id` varchar(20) DEFAULT NULL COMMENT 'Columna donde irá el id de la opcion que se identifica en la columna module_id',
  `option` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`audit_log_id`) USING BTREE,
  KEY `fk_audit1_idx` (`client_id`) USING BTREE,
  KEY `fk_audit2_idx` (`user_id`) USING BTREE,
  KEY `fk_audit3_idx` (`module_id`) USING BTREE,
  KEY `index_created` (`date`) USING BTREE,
  CONSTRAINT `fk_audit1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`),
  CONSTRAINT `fk_audit2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
  CONSTRAINT `fk_audit3` FOREIGN KEY (`module_id`) REFERENCES `module` (`module_id`)
) ENGINE=InnoDB AUTO_INCREMENT=23817 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `auth_item_types`
--

DROP TABLE IF EXISTS `auth_item_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `auth_item_types` (
  `item_type_id` smallint NOT NULL AUTO_INCREMENT,
  `name` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`item_type_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `auth_items`
--

DROP TABLE IF EXISTS `auth_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `auth_items` (
  `name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `type` smallint NOT NULL,
  `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci,
  `rule_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `data` blob,
  `order` int DEFAULT NULL,
  `created_at` int DEFAULT NULL,
  `updated_at` int DEFAULT NULL,
  `icon` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `permission_type` smallint DEFAULT '0' COMMENT 'Columna para identificar qué opciones saldrán para asignación de permisos para Clientes e Integradores:\n0: Permiso no asociado - No carga para asignación en dichos módulos\n1: Permiso asociado - Carga para asignación en dichos módulos',
  PRIMARY KEY (`name`) USING BTREE,
  KEY `idx-auth_item-type` (`type`) USING BTREE,
  KEY `auth_item_ibfk_1` (`rule_name`) USING BTREE,
  CONSTRAINT `auth_item_ibfk_2` FOREIGN KEY (`type`) REFERENCES `auth_item_types` (`item_type_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bridges`
--

DROP TABLE IF EXISTS `bridges`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bridges` (
  `bridge_id` varchar(50) NOT NULL,
  `name` varchar(100) NOT NULL,
  `account_id` varchar(50) NOT NULL,
  `client_id` int NOT NULL,
  `service_status` varchar(10) NOT NULL,
  `guid` varchar(100) NOT NULL,
  `serial_number` varchar(100) NOT NULL,
  `device_status` int NOT NULL,
  `location` varchar(700) NOT NULL,
  PRIMARY KEY (`bridge_id`) USING BTREE,
  KEY `client_id` (`client_id`) USING BTREE,
  CONSTRAINT `bridges_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `brivo_events`
--

DROP TABLE IF EXISTS `brivo_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `brivo_events` (
  `uuid` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `object_type` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `event_object_id` int NOT NULL,
  `event_object_name` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `actor_id` int NOT NULL,
  `actor_name` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `object_name` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `object_group_name` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `object_type_id` int NOT NULL,
  `action_allowed` int NOT NULL,
  `detail` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `credentials` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `security_action` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `site_id` int NOT NULL,
  `occurred` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`uuid`) USING BTREE,
  KEY `site_id` (`site_id`) USING BTREE,
  CONSTRAINT `brivo_events_ibfk_1` FOREIGN KEY (`site_id`) REFERENCES `brivo_sites` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `brivo_sites`
--

DROP TABLE IF EXISTS `brivo_sites`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `brivo_sites` (
  `id` int NOT NULL,
  `site_name` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `street_address1` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `street_address2` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `city` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `state` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `postal_code` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `cameras`
--

DROP TABLE IF EXISTS `cameras`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cameras` (
  `camera_id` int NOT NULL AUTO_INCREMENT,
  `id` varchar(20) NOT NULL,
  `client_id` int NOT NULL DEFAULT '1',
  `account_id` int DEFAULT NULL,
  `type` varchar(20) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `address` varchar(100) DEFAULT NULL,
  `district_id` int DEFAULT NULL,
  `neighborhood` varchar(150) DEFAULT NULL,
  `legacy_city_id` varchar(6) DEFAULT NULL,
  `business_type` varchar(255) DEFAULT NULL,
  `latitude` decimal(18,15) DEFAULT NULL,
  `longitude` decimal(18,15) DEFAULT NULL,
  `analytics` text,
  `data` text,
  `status` tinyint DEFAULT NULL,
  `user_id` int DEFAULT '1',
  `zone_id` int DEFAULT NULL,
  `bridge_id` varchar(50) DEFAULT NULL,
  `snapshot_path` varchar(255) DEFAULT NULL,
  `active` int DEFAULT '1',
  `date` datetime DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `city_id` int unsigned DEFAULT NULL,
  PRIMARY KEY (`camera_id`) USING BTREE,
  KEY `account_id` (`account_id`) USING BTREE,
  KEY `client_id` (`client_id`) USING BTREE,
  KEY `camera_ibfk_5` (`user_id`),
  KEY `cameras_ibfk_1` (`legacy_city_id`),
  KEY `cameras_ibfk_2` (`district_id`),
  KEY `camera_ibfk_7` (`bridge_id`),
  KEY `fk_cameras_city_id` (`city_id`),
  CONSTRAINT `camera_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`account_id`),
  CONSTRAINT `camera_ibfk_4` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`),
  CONSTRAINT `camera_ibfk_5` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
  CONSTRAINT `camera_ibfk_7` FOREIGN KEY (`bridge_id`) REFERENCES `bridges` (`bridge_id`),
  CONSTRAINT `cameras_ibfk_2` FOREIGN KEY (`district_id`) REFERENCES `districts` (`district_id`),
  CONSTRAINT `fk_cameras_city_id` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1116 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `cities`
--

DROP TABLE IF EXISTS `cities`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cities` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `city_id` varchar(6) NOT NULL,
  `state_id` int DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_city_id` (`city_id`),
  KEY `state_id` (`state_id`) USING BTREE,
  CONSTRAINT `city_ibfk_1` FOREIGN KEY (`state_id`) REFERENCES `states` (`state_id`)
) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `client_auth_items`
--

DROP TABLE IF EXISTS `client_auth_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_auth_items` (
  `client_item_id` int NOT NULL AUTO_INCREMENT,
  `client_id` int DEFAULT NULL,
  `item_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `user_id` int DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  PRIMARY KEY (`client_item_id`) USING BTREE,
  KEY `client_item_ibfk_1_idx` (`client_id`) USING BTREE,
  KEY `client_item_ibfk_2_idx` (`user_id`) USING BTREE,
  KEY `client_item_ibfk_3_idx` (`item_name`) USING BTREE,
  CONSTRAINT `client_item_ibfk_1_idx` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`),
  CONSTRAINT `client_item_ibfk_3_idx` FOREIGN KEY (`item_name`) REFERENCES `auth_items` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=323 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `clients`
--

DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
  `client_id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `integrator_id` int NOT NULL COMMENT 'Integrador',
  `name` varchar(100) NOT NULL COMMENT 'Nombre',
  `address` varchar(100) DEFAULT NULL COMMENT 'Dirección',
  `contact_name` varchar(150) DEFAULT NULL COMMENT 'Responsable',
  `phone` varchar(20) DEFAULT NULL COMMENT 'Teléfono',
  `phone2` varchar(20) DEFAULT NULL COMMENT 'Celular',
  `user_id` int DEFAULT NULL COMMENT 'Usuario',
  `modified_user_id` int DEFAULT NULL,
  `active` int NOT NULL DEFAULT '1' COMMENT 'Activo',
  `date` datetime DEFAULT NULL COMMENT 'Fecha',
  `created` datetime DEFAULT NULL,
  `status` int DEFAULT '9' COMMENT 'Estado',
  PRIMARY KEY (`client_id`) USING BTREE,
  KEY `integrator_id` (`integrator_id`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE,
  CONSTRAINT `client_ibfk_1` FOREIGN KEY (`integrator_id`) REFERENCES `integrators` (`integrator_id`)
) ENGINE=InnoDB AUTO_INCREMENT=76 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `districts`
--

DROP TABLE IF EXISTS `districts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `districts` (
  `district_id` int NOT NULL AUTO_INCREMENT,
  `legacy_city_id` varchar(6) DEFAULT NULL,
  `id` int DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `city_id` int unsigned DEFAULT NULL,
  PRIMARY KEY (`district_id`) USING BTREE,
  KEY `city_id` (`legacy_city_id`) USING BTREE,
  KEY `fk_districts_city_id` (`city_id`),
  CONSTRAINT `fk_districts_city_id` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=308 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `download_videos`
--

DROP TABLE IF EXISTS `download_videos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `download_videos` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `camera` varchar(30) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `rango` varchar(255) DEFAULT NULL,
  `recording` varchar(50) DEFAULT NULL,
  `token` varchar(255) DEFAULT NULL,
  `job` varchar(255) DEFAULT NULL,
  `estado` varchar(255) DEFAULT 'INICIANDO',
  `fecha_registro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `fecha_generacion_video` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `url_video` text,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `fk_download_videos_users` (`user_id`),
  CONSTRAINT `fk_download_videos_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=496 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `events`
--

DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `events` (
  `event_id` varchar(100) NOT NULL,
  `site_id` varchar(100) DEFAULT NULL,
  `source_id` varchar(100) DEFAULT NULL,
  `date` bigint DEFAULT NULL,
  `start_time` bigint DEFAULT NULL,
  `end_time` bigint DEFAULT NULL,
  `type` varchar(20) DEFAULT NULL,
  `root_person_id` varchar(100) DEFAULT NULL,
  `root_person_add_date` bigint DEFAULT NULL,
  `person_id` varchar(100) DEFAULT NULL,
  `age` float DEFAULT NULL,
  `gender` varchar(10) DEFAULT NULL,
  `max_sentiment` float DEFAULT NULL,
  `min_sentiment` float DEFAULT NULL,
  `avg_sentiment` float DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `auto_ended` tinyint(1) DEFAULT NULL,
  `home_location` varchar(100) DEFAULT NULL,
  `similarity_score` float DEFAULT NULL,
  `direct_gaze_duration` int DEFAULT NULL,
  `id_class` varchar(20) DEFAULT NULL,
  `new_id` bigint DEFAULT NULL,
  `top_at_start` float DEFAULT NULL,
  `left_at_start` float DEFAULT NULL,
  `height_at_start` float DEFAULT NULL,
  `width_at_start` float DEFAULT NULL,
  `top` float DEFAULT NULL,
  `left` float DEFAULT NULL,
  `height` float DEFAULT NULL,
  `width` float DEFAULT NULL,
  `image_time` bigint DEFAULT NULL,
  `occlusion` float DEFAULT NULL,
  `cpq` float DEFAULT NULL,
  `pitch` float DEFAULT NULL,
  `roll` float DEFAULT NULL,
  `yaw` float DEFAULT NULL,
  `mask` tinyint(1) DEFAULT NULL,
  `src_user_id` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`event_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `groups`
--

DROP TABLE IF EXISTS `groups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `groups` (
  `group_id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(50) DEFAULT NULL,
  `name` varchar(100) NOT NULL,
  `color` varchar(50) NOT NULL,
  `threshold_delta` int DEFAULT NULL,
  `watchlist_type` varchar(50) DEFAULT NULL,
  `active` tinyint NOT NULL,
  `date` datetime DEFAULT NULL,
  PRIMARY KEY (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `integrator_auth_items`
--

DROP TABLE IF EXISTS `integrator_auth_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `integrator_auth_items` (
  `integrator_item_id` int NOT NULL AUTO_INCREMENT,
  `integrator_id` int DEFAULT NULL,
  `item_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `user_id` int DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  PRIMARY KEY (`integrator_item_id`) USING BTREE,
  KEY `integrator_item_ibfk_1_idx` (`integrator_id`) USING BTREE,
  KEY `integrator_item_ibfk_2_idx` (`user_id`) USING BTREE,
  KEY `integrator_item_ibfk_3_idx` (`item_name`) USING BTREE,
  CONSTRAINT `integrator_item_ibf_1` FOREIGN KEY (`integrator_id`) REFERENCES `integrators` (`integrator_id`),
  CONSTRAINT `integrator_item_ibf_3` FOREIGN KEY (`item_name`) REFERENCES `auth_items` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `integrators`
--

DROP TABLE IF EXISTS `integrators`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `integrators` (
  `integrator_id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(100) NOT NULL COMMENT 'Nombre',
  `address` varchar(100) DEFAULT NULL COMMENT 'Dirección',
  `contact_name` varchar(150) DEFAULT NULL COMMENT 'Responsable',
  `phone` varchar(20) DEFAULT NULL COMMENT 'Teléfono',
  `phone2` varchar(20) DEFAULT NULL COMMENT 'Celular',
  `user_id` int DEFAULT NULL COMMENT 'Usuario',
  `modified_user_id` int DEFAULT NULL,
  `active` int NOT NULL DEFAULT '1' COMMENT 'Activo',
  `date` datetime DEFAULT NULL COMMENT 'Fecha',
  `created` datetime DEFAULT NULL,
  `status` int DEFAULT '9' COMMENT 'Estado',
  PRIMARY KEY (`integrator_id`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mobile_operators`
--

DROP TABLE IF EXISTS `mobile_operators`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mobile_operators` (
  `mobile_operator_id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(20) DEFAULT NULL,
  `apn` varchar(100) DEFAULT NULL,
  `username` varchar(20) DEFAULT NULL,
  `password` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`mobile_operator_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `module`
--

DROP TABLE IF EXISTS `module`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `module` (
  `module_id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`module_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `neighborhoods`
--

DROP TABLE IF EXISTS `neighborhoods`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `neighborhoods` (
  `neighborhood_id` int NOT NULL AUTO_INCREMENT,
  `district_id` int NOT NULL,
  `name` varchar(150) NOT NULL,
  PRIMARY KEY (`neighborhood_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2549 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `people`
--

DROP TABLE IF EXISTS `people`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `people` (
  `person_id` int NOT NULL AUTO_INCREMENT,
  `person_group_id` int NOT NULL,
  `name` varchar(150) NOT NULL,
  `lastname` varchar(150) DEFAULT NULL,
  `document_type_id` int DEFAULT NULL,
  `document` varchar(50) DEFAULT NULL,
  `citizenship` varchar(50) DEFAULT NULL,
  `gender` char(1) DEFAULT NULL,
  `age` int DEFAULT NULL,
  `eye_color` varchar(50) DEFAULT NULL,
  `height` int DEFAULT NULL,
  `description` text,
  `suspect_id` varchar(50) DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  PRIMARY KEY (`person_id`) USING BTREE,
  KEY `person_group_id` (`person_group_id`) USING BTREE,
  CONSTRAINT `people_ibfk_1` FOREIGN KEY (`person_group_id`) REFERENCES `groups` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `personal_access_tokens`
--

DROP TABLE IF EXISTS `personal_access_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `personal_access_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tokenable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tokenable_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `abilities` text COLLATE utf8mb4_unicode_ci,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
  KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
) ENGINE=InnoDB AUTO_INCREMENT=61126 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `plate_files`
--

DROP TABLE IF EXISTS `plate_files`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `plate_files` (
  `plate_file_id` int NOT NULL AUTO_INCREMENT,
  `type_id` tinyint NOT NULL,
  `code` varchar(100) NOT NULL,
  `filename` varchar(255) NOT NULL,
  `etag` varchar(50) DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  PRIMARY KEY (`plate_file_id`) USING BTREE,
  KEY `type_id` (`type_id`) USING BTREE,
  CONSTRAINT `plate_files_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `type` (`type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `plates`
--

DROP TABLE IF EXISTS `plates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `plates` (
  `plate_id` int NOT NULL AUTO_INCREMENT,
  `plate_file_id` int DEFAULT NULL,
  `plate` varchar(10) DEFAULT NULL COMMENT 'Matrícula/Placa reconocida.',
  `country` varchar(45) DEFAULT NULL COMMENT 'Nombre del país reconocido',
  `neural_country_id` int DEFAULT NULL COMMENT 'ID del país reconocido',
  `neural_camera_id` int DEFAULT NULL COMMENT 'Identificador de la cámara que ha realizado la lectura.',
  `neural_camera_name` varchar(45) DEFAULT NULL COMMENT 'Nombre de la cámara que ha realizado la lectura.',
  `image_path` text COMMENT 'Directorio donde queda almacenada la imagen en el equipo que realiza el reconocimiento.',
  `vehicle_make` varchar(45) DEFAULT NULL COMMENT 'Analítica de marca del vehículo detectado.',
  `vehicle_class` varchar(45) DEFAULT NULL COMMENT 'Analítica de clasificación del vehículo detectado.',
  `vehicle_color` varchar(45) DEFAULT NULL COMMENT 'Analítica de color del vehículo detectado.',
  `created` datetime DEFAULT NULL COMMENT 'Fecha de creación del registro',
  `date` datetime DEFAULT NULL COMMENT 'Fecha de modificación del registro',
  `date_detection` datetime DEFAULT NULL,
  `image` longblob COMMENT 'Imagen codificada en Base64',
  `image_url` varchar(255) DEFAULT NULL COMMENT 'Url imagen',
  `speed` double DEFAULT NULL COMMENT 'Velocidad instantánea del Vehículo si esta activa',
  `latitude` varchar(45) DEFAULT NULL,
  `longitude` varchar(45) DEFAULT NULL,
  `list_id` int DEFAULT NULL COMMENT 'Id de la lista para la placa',
  `list_name` varchar(45) DEFAULT NULL COMMENT 'Nombre de la lista',
  `engine` varchar(10) DEFAULT NULL COMMENT 'Usado en Neural: Motor de Reconocimiento LPR / ACCR',
  `location_id` varchar(45) DEFAULT NULL,
  `type_id` tinyint DEFAULT NULL COMMENT 'Tipo de medio por donde llega la información de las placas',
  `observations` text,
  `status` tinyint(1) DEFAULT '0' COMMENT '0: Pendiente\\n1: Atendida',
  `state` varchar(45) DEFAULT NULL,
  `city` varchar(45) DEFAULT NULL,
  `type_processing` tinyint(1) DEFAULT '0' COMMENT '0: Tipo de Procesamiento no definido\\n1. Stream de Video\\n2. Forence',
  `image_cood` text COMMENT 'Campo para coordenadas de posicionamiento de la placa en la imagen',
  `amount` int DEFAULT NULL COMMENT 'Cantidad',
  PRIMARY KEY (`plate_id`) USING BTREE,
  KEY `plate_ibfk_1_idx` (`type_id`) USING BTREE,
  KEY `plate_file_id` (`plate_file_id`) USING BTREE,
  CONSTRAINT `plates_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `type` (`type_id`),
  CONSTRAINT `plates_ibfk_2` FOREIGN KEY (`plate_file_id`) REFERENCES `plate_files` (`plate_file_id`)
) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `query_events`
--

DROP TABLE IF EXISTS `query_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `query_events` (
  `query_id` int NOT NULL AUTO_INCREMENT,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`query_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=692072 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `states`
--

DROP TABLE IF EXISTS `states`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `states` (
  `state_id` int NOT NULL,
  `country_id` int NOT NULL DEFAULT '1',
  `name` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`state_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `type`
--

DROP TABLE IF EXISTS `type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `type` (
  `type_id` tinyint NOT NULL AUTO_INCREMENT,
  `type` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`type_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `users`
--

DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `user_id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `auth_item_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Rol',
  `integrator_id` int DEFAULT NULL COMMENT 'Integrador',
  `client_id` int DEFAULT NULL COMMENT 'Cliente',
  `imei` varchar(20) DEFAULT NULL COMMENT 'Alarma',
  `username` varchar(255) NOT NULL COMMENT 'Usuario',
  `password_hash` varchar(100) DEFAULT NULL,
  `password_reset_token` varchar(100) DEFAULT NULL,
  `verification_token` varchar(100) DEFAULT NULL,
  `verification_token_status` smallint NOT NULL DEFAULT '0',
  `name` varchar(100) DEFAULT NULL COMMENT 'Nombre',
  `email` varchar(255) DEFAULT NULL COMMENT 'e-mail',
  `auth_key` varchar(32) DEFAULT NULL,
  `change_password` tinyint NOT NULL DEFAULT '0',
  `status` int DEFAULT NULL COMMENT 'Estado',
  `active` int DEFAULT '1',
  `user_modified_id` int DEFAULT NULL,
  `created_at` datetime DEFAULT NULL COMMENT 'Fecha Registro',
  `updated_at` datetime DEFAULT NULL COMMENT 'Fecha actualización',
  `phone` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`user_id`),
  KEY `user_ibfk_2` (`auth_item_name`),
  KEY `user_ibfk_3` (`integrator_id`),
  KEY `user_ibfk_4` (`client_id`),
  CONSTRAINT `user_ibfk_2` FOREIGN KEY (`auth_item_name`) REFERENCES `auth_items` (`name`) ON UPDATE CASCADE,
  CONSTRAINT `user_ibfk_3` FOREIGN KEY (`integrator_id`) REFERENCES `integrators` (`integrator_id`),
  CONSTRAINT `user_ibfk_4` FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=227 DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `users_alarms`
--

DROP TABLE IF EXISTS `users_alarms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_alarms` (
  `user_id` int NOT NULL,
  `imei` varchar(20) NOT NULL,
  `assigned_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`user_id`,`imei`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-02-17  9:09:48
