-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 08-05-2025 a las 02:16:32
-- Versión del servidor: 10.4.32-MariaDB
-- Versión de PHP: 8.2.12

START TRANSACTION;



--
-- Base de datos: `carpooling`
--

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

--
-- Estructura de tabla para la tabla `calificaciones`
--

CREATE TABLE `calificaciones` (
  `id` int(11) NOT NULL,
  `id_evaluador` int(11) NOT NULL,
  `id_evaluado` int(11) NOT NULL,
  `id_ruta` int(11) NOT NULL,
  `puntaje` float DEFAULT NULL,
  `observaciones` varchar(300) DEFAULT 'NA',
  `tipo_evaluado` enum('Conductor','Pasajero') NOT NULL,
  `estado` tinyint(1) DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Estructura de tabla para la tabla `conductor`
--

CREATE TABLE `conductor` (
  `id` int(11) NOT NULL,
  `id_estudiante` int(11) NOT NULL,
  `licencia` varchar(250) NOT NULL,
  `licencia_pdf` varchar(255) NOT NULL,
  `puntaje` float NOT NULL DEFAULT 5,
  `estado` tinyint(1) DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Estructura de tabla para la tabla `estudiante`
--

CREATE TABLE `estudiante` (
  `id` int(11) NOT NULL,
  `id_user` bigint(20) UNSIGNED NOT NULL,
  `nombre` varchar(250) NOT NULL,
  `tipo_doc` varchar(255) NOT NULL,
  `identificacion` char(15) NOT NULL,
  `pdf_id` varchar(255) NOT NULL,
  `direccion` varchar(250) DEFAULT 'NA',
  `telefono` char(15) DEFAULT 'NA',
  `eps` varchar(255) DEFAULT 'NA',
  `certificado_eps` varchar(255) NOT NULL,
  `foto_perfil` varchar(255) NOT NULL,
  `isConductor` tinyint(1) DEFAULT 0,
  `puntaje` float DEFAULT 5,
  `estado` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Estructura de tabla para la tabla `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(191) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Estructura de tabla para la tabla `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Estructura de tabla para la tabla `model_has_permissions`
--

CREATE TABLE `model_has_permissions` (
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Estructura de tabla para la tabla `model_has_roles`
--

CREATE TABLE `model_has_roles` (
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `model_has_roles`
--

INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES
(1, 'App\\Models\\User', 1),
(5, 'App\\Models\\User', 7),
(5, 'App\\Models\\User', 8),
(5, 'App\\Models\\User', 9),
(5, 'App\\Models\\User', 10),
(5, 'App\\Models\\User', 11),
(5, 'App\\Models\\User', 12),
(5, 'App\\Models\\User', 13),
(5, 'App\\Models\\User', 14),
(5, 'App\\Models\\User', 15),
(5, 'App\\Models\\User', 16),
(5, 'App\\Models\\User', 17),
(5, 'App\\Models\\User', 18),
(5, 'App\\Models\\User', 19),
(5, 'App\\Models\\User', 20),
(5, 'App\\Models\\User', 21),
(5, 'App\\Models\\User', 22),
(5, 'App\\Models\\User', 23),
(5, 'App\\Models\\User', 25),
(5, 'App\\Models\\User', 26),
(5, 'App\\Models\\User', 28),
(6, 'App\\Models\\User', 9),
(6, 'App\\Models\\User', 10),
(6, 'App\\Models\\User', 11),
(6, 'App\\Models\\User', 14),
(6, 'App\\Models\\User', 19),
(6, 'App\\Models\\User', 20),
(6, 'App\\Models\\User', 21),
(6, 'App\\Models\\User', 22),
(6, 'App\\Models\\User', 23),
(7, 'App\\Models\\User', 27);

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

--
-- Estructura de tabla para la tabla `permissions`
--

CREATE TABLE `permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(125) NOT NULL,
  `guard_name` varchar(125) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `permissions`
--

INSERT INTO `permissions` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
(1, 'rol-listar', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(2, 'rol-crear', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(3, 'rol-editar', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(4, 'rol-eliminar', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(5, 'usuarios-listar', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(6, 'usuarios-crear', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(7, 'usuarios-editar', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(8, 'usuarios-eliminar', 'web', '2024-08-05 19:25:20', '2024-08-05 19:25:20'),
(46, 'solicitudes_conductor-listar', 'web', '2025-02-06 00:46:55', '2025-02-06 00:46:55'),
(47, 'solicitudes_conductor-crear', 'web', '2025-02-06 00:46:55', '2025-02-06 00:46:55'),
(48, 'solicitudes_conductor-editar', 'web', '2025-02-06 00:46:55', '2025-02-06 00:46:55'),
(49, 'solicitudes_conductor-eliminar', 'web', '2025-02-06 00:46:55', '2025-02-06 00:46:55'),
(50, 'rutas-listar', 'web', '2025-02-13 13:09:14', '2025-02-13 13:09:14'),
(51, 'rutas-crear', 'web', '2025-02-13 13:09:14', '2025-02-13 13:09:14'),
(52, 'rutas-editar', 'web', '2025-02-13 13:09:14', '2025-02-13 13:09:14'),
(53, 'rutas-eliminar', 'web', '2025-02-13 13:09:14', '2025-02-13 13:09:14'),
(54, 'solicitudes_rutas-listar', 'web', '2025-02-26 23:58:46', '2025-02-26 23:58:46'),
(55, 'solicitudes_rutas-crear', 'web', '2025-02-26 23:58:46', '2025-02-26 23:58:46'),
(56, 'solicitudes_rutas-editar', 'web', '2025-02-26 23:58:46', '2025-02-26 23:58:46'),
(57, 'solicitudes_rutas-eliminar', 'web', '2025-02-26 23:58:46', '2025-02-26 23:58:46'),
(58, 'solicitar_viajes-listar', 'web', '2025-03-04 19:40:05', '2025-03-04 19:40:05'),
(59, 'solicitar_viajes-crear', 'web', '2025-03-04 19:40:05', '2025-03-04 19:40:05'),
(60, 'solicitar_viajes-editar', 'web', '2025-03-04 19:40:05', '2025-03-04 19:40:05'),
(61, 'solicitar_viajes-eliminar', 'web', '2025-03-04 19:40:05', '2025-03-04 19:40:05'),
(62, 'configuracion-sistema', 'web', '2025-03-05 03:07:59', '2025-03-05 03:07:59'),
(63, 'solicitudes_pasajero-listar', 'web', '2025-03-06 20:43:23', '2025-03-06 20:43:23'),
(64, 'solicitudes_pasajero-crear', 'web', '2025-03-06 20:43:23', '2025-03-06 20:43:23'),
(65, 'solicitudes_pasajero-editar', 'web', '2025-03-06 20:43:23', '2025-03-06 20:43:23'),
(66, 'solicitudes_pasajero-eliminar', 'web', '2025-03-06 20:43:23', '2025-03-06 20:43:23');

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

--
-- Estructura de tabla para la tabla `roles`
--

CREATE TABLE `roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(125) NOT NULL,
  `guard_name` varchar(125) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `roles`
--

INSERT INTO `roles` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
(1, 'Super administrador', 'web', '2024-08-05 19:25:28', '2025-04-09 17:22:25'),
(5, 'Pasajero', 'web', '2025-02-05 20:22:56', '2025-02-05 20:22:56'),
(6, 'Conductor', 'web', '2025-02-10 17:05:27', '2025-02-10 17:05:27'),
(7, 'Aprobador', 'web', '2025-04-09 18:00:40', '2025-04-09 18:00:40');

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

--
-- Estructura de tabla para la tabla `role_has_permissions`
--

CREATE TABLE `role_has_permissions` (
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `role_has_permissions`
--

INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES
(1, 1),
(2, 1),
(3, 1),
(4, 1),
(5, 1),
(5, 7),
(6, 1),
(6, 7),
(7, 1),
(7, 7),
(8, 1),
(46, 1),
(46, 7),
(47, 1),
(47, 7),
(48, 1),
(48, 7),
(49, 1),
(49, 7),
(50, 6),
(51, 6),
(52, 6),
(53, 6),
(54, 6),
(55, 6),
(56, 6),
(57, 6),
(58, 5),
(59, 5),
(60, 5),
(61, 5),
(62, 1),
(62, 7),
(63, 5),
(64, 5),
(65, 5),
(66, 5);

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

--
-- Estructura de tabla para la tabla `rutas`
--

CREATE TABLE `rutas` (
  `id` int(11) NOT NULL,
  `id_conductor` int(11) NOT NULL,
  `id_vehiculo` int(11) NOT NULL,
  `origen` varchar(500) NOT NULL,
  `destino` varchar(500) NOT NULL,
  `fecha_hora` datetime NOT NULL,
  `puestos_disponibles` int(11) NOT NULL,
  `lat_origen` varchar(250) NOT NULL,
  `long_origen` varchar(250) NOT NULL,
  `lat_destino` varchar(250) NOT NULL,
  `long_destino` varchar(250) NOT NULL,
  `kilometros` float(12,2) NOT NULL,
  `indicaciones` varchar(255) DEFAULT NULL,
  `estado` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Estructura de tabla para la tabla `solicitudes_ruta`
--

CREATE TABLE `solicitudes_ruta` (
  `id` int(11) NOT NULL,
  `id_ruta` int(11) NOT NULL,
  `id_estudiante` int(11) NOT NULL,
  `observaciones` varchar(300) DEFAULT NULL,
  `estado` enum('pendiente','aprobado','rechazado','finalizado','cancelado') DEFAULT 'pendiente',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Estructura de tabla para la tabla `vehiculos`
--

CREATE TABLE `vehiculos` (
  `id` int(11) NOT NULL,
  `id_conductor` int(11) NOT NULL,
  `soat` varchar(250) NOT NULL,
  `fecha_v_soat` varchar(100) NOT NULL,
  `tecnico_mecanica` varchar(250) DEFAULT 'NA',
  `fecha_v_mecanica` varchar(100) DEFAULT 'NA',
  `foto_vehiculo` varchar(250) NOT NULL,
  `modelo_vehiculo` char(10) NOT NULL,
  `marca_vehiculo` varchar(255) NOT NULL,
  `linea_vehiculo` varchar(255) NOT NULL,
  `tarjeta_propiedad` varchar(250) NOT NULL,
  `placa` char(10) NOT NULL,
  `estado` tinyint(1) DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Índices para tablas volcadas
--

--
-- Indices de la tabla `calificaciones`
--
ALTER TABLE `calificaciones`
  ADD PRIMARY KEY (`id`),
  ADD KEY `ruta` (`id_ruta`);

--
-- Indices de la tabla `conductor`
--
ALTER TABLE `conductor`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_estudiante` (`id_estudiante`);

--
-- Indices de la tabla `estudiante`
--
ALTER TABLE `estudiante`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_user` (`id_user`);

--
-- Indices de la tabla `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indices de la tabla `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indices de la tabla `model_has_permissions`
--
ALTER TABLE `model_has_permissions`
  ADD PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  ADD KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`);

--
-- Indices de la tabla `model_has_roles`
--
ALTER TABLE `model_has_roles`
  ADD PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  ADD KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`);

--
-- Indices de la tabla `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`);

--
-- Indices de la tabla `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`);

--
-- Indices de la tabla `role_has_permissions`
--
ALTER TABLE `role_has_permissions`
  ADD PRIMARY KEY (`permission_id`,`role_id`),
  ADD KEY `role_has_permissions_role_id_foreign` (`role_id`);

--
-- Indices de la tabla `rutas`
--
ALTER TABLE `rutas`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_conductor` (`id_conductor`),
  ADD KEY `id_vehiculo` (`id_vehiculo`);

--
-- Indices de la tabla `solicitudes_ruta`
--
ALTER TABLE `solicitudes_ruta`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_estudiante` (`id_estudiante`),
  ADD KEY `id_ruta` (`id_ruta`);

--
-- Indices de la tabla `vehiculos`
--
ALTER TABLE `vehiculos`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_conductor` (`id_conductor`);

--
-- AUTO_INCREMENT de las tablas volcadas
--

--
-- AUTO_INCREMENT de la tabla `calificaciones`
--
ALTER TABLE `calificaciones`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=53;

--
-- AUTO_INCREMENT de la tabla `conductor`
--
ALTER TABLE `conductor`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;

--
-- AUTO_INCREMENT de la tabla `estudiante`
--
ALTER TABLE `estudiante`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;

--
-- AUTO_INCREMENT de la tabla `failed_jobs`
--
ALTER TABLE `failed_jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=67;

--
-- AUTO_INCREMENT de la tabla `roles`
--
ALTER TABLE `roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT de la tabla `rutas`
--
ALTER TABLE `rutas`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34;

--
-- AUTO_INCREMENT de la tabla `solicitudes_ruta`
--
ALTER TABLE `solicitudes_ruta`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=37;

--
-- AUTO_INCREMENT de la tabla `vehiculos`
--
ALTER TABLE `vehiculos`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `calificaciones`
--
ALTER TABLE `calificaciones`
  ADD CONSTRAINT `ruta` FOREIGN KEY (`id_ruta`) REFERENCES `rutas` (`id`);

--
-- Filtros para la tabla `conductor`
--
ALTER TABLE `conductor`
  ADD CONSTRAINT `id_estudiante` FOREIGN KEY (`id_estudiante`) REFERENCES `estudiante` (`id`);

--
-- Filtros para la tabla `estudiante`
--
ALTER TABLE `estudiante`
  ADD CONSTRAINT `id_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`);

--
-- Filtros para la tabla `model_has_permissions`
--
ALTER TABLE `model_has_permissions`
  ADD CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `model_has_roles`
--
ALTER TABLE `model_has_roles`
  ADD CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `role_has_permissions`
--
ALTER TABLE `role_has_permissions`
  ADD CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `rutas`
--
ALTER TABLE `rutas`
  ADD CONSTRAINT `id_conductor` FOREIGN KEY (`id_conductor`) REFERENCES `conductor` (`id`),
  ADD CONSTRAINT `id_vehiculo` FOREIGN KEY (`id_vehiculo`) REFERENCES `vehiculos` (`id`);

--
-- Filtros para la tabla `solicitudes_ruta`
--
ALTER TABLE `solicitudes_ruta`
  ADD CONSTRAINT `estudiante` FOREIGN KEY (`id_estudiante`) REFERENCES `estudiante` (`id`),
  ADD CONSTRAINT `id_rura` FOREIGN KEY (`id_ruta`) REFERENCES `rutas` (`id`);
COMMIT;

