create database citas_juzgados;


CREATE TABLE IF NOT EXISTS `citas_juzgados`.`cat_juzgados` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `nombre_juzgado` VARCHAR(145) NOT NULL,
  `partido_judicial` INT(1) NOT NULL,
  `activo_juzgado` TINYINT(1) NOT NULL,
  `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `citas_juzgados`.`cat_asuntos` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `descripcion_asunto` VARCHAR(145) NOT NULL,
  `duracion_asunto` VARCHAR(50) NOT NULL,
  `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `citas_juzgados`.`tbl_agenda_juzgados` (
  `id` INT(11) NOT NULL,
  `cat_juzgados_id` INT(3) NOT NULL,
  `cat_asuntos_id` INT(3) NOT NULL,
  `hora_cita` VARCHAR(50) NOT NULL,
  `fecha_cita` VARCHAR(50) NOT NULL,
  `expediente` VARCHAR(45) NOT NULL,
  `nombre_persona` VARCHAR(145) NOT NULL,
  `telefono` VARCHAR(45) NOT NULL,
  `correo` VARCHAR(70) NOT NULL,
  `activa` TINYINT(1) NOT NULL,
  `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;

CREATE TABLE `tbl_horarios_disponibles` (
  `id` int(11) NOT NULL,
  `inicio` time DEFAULT NULL,
  `fin` time DEFAULT NULL
) ENGINE=InnoDB;
/*
1	09:00:00	09:30:00
2	09:30:00	10:00:00
3	10:00:00	10:30:00
4	10:30:00	11:00:00
5	11:00:00	11:30:00
6	11:30:00	12:00:00
7	12:00:00	12:30:00
8	12:30:00	01:00:00
9	01:00:00	01:30:00
10	01:30:00	02:00:00
*/

ALTER TABLE `citas_juzgados`.`tbl_agenda_juzgados` 
CHANGE COLUMN `id` `id` INT NOT NULL AUTO_INCREMENT ;
