CREATE TABLE `proyecto` (
  `id` char(36) NOT NULL,
  `id_propietario` char(36) NOT NULL,
  `nombre_proyecto` text NOT NULL,
  `costo_terreno` double DEFAULT NULL,
  `anticipo` double DEFAULT NULL,
  `compromiso_pago` enum('MENSUAL','ANUAL','TRIMESTRAL') DEFAULT NULL,
  `comision_mensual` double DEFAULT NULL,
  `interes_mensual` double DEFAULT NULL,
  `id_location` char(36) NOT NULL,
  `created_by` char(36) NOT NULL,
  `created_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `last_updated_by` char(36) DEFAULT NULL,
  `last_updated_on` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `manzana` (
  `id` char(36) NOT NULL,
  `id_proyecto` char(36) NOT NULL,
  `nombre` text NOT NULL,
  `num_lotes` int NOT NULL,
  `created_by` char(36) NOT NULL,
  `created_on` datetime NOT NULL,
  `last_updated_by` char(36) DEFAULT NULL,
  `last_updated_on` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `lote` (
  `id` char(36) DEFAULT NULL,
  `medida` double DEFAULT NULL,
  `metro_cuadrado` double DEFAULT NULL,
  `estatus` enum('DISPONIBLE','VENDIDO','APARTADO') DEFAULT NULL,
  `anticipo` double DEFAULT NULL,
  `plazo_meses` text,
  `periodo_pago` enum('MENSUAL','QUINCENAL') DEFAULT NULL,
  `dia_a_pagar` text,
  `costo` double DEFAULT NULL,
  `total_a_pagar` double DEFAULT NULL,
  `mensualidad` double DEFAULT NULL,
  `id_cliente` char(36) DEFAULT NULL,
  `id_manzana` char(36) DEFAULT NULL,
  `created_by` char(36) NOT NULL,
  `created_on` datetime NOT NULL,
  `last_updated_by` char(36) DEFAULT NULL,
  `last_updated_on` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
SELECT * FROM crov_inmobiliaria.lote;


######################

CREATE TABLE `abono_proyecto` (
  `id` char(36) NOT NULL,
  `id_proyecto` char(36) NOT NULL,
  `tipo_abono` enum('ANTICIPO','ABONO') DEFAULT NULL,
  `estatus_activo` enum('ENABLED','DISABLED') DEFAULT 'DISABLED',
  `pago_estatus` enum('ENABLED','DISABLED') DEFAULT 'DISABLED',
  `fecha_a_pagar` date NOT NULL,
  `pago` double NOT NULL,
  `saldo_anterior` double NOT NULL,
  `saldo_nuevo` double NOT NULL,
  `created_on` date NOT NULL,
  `created_by` char(36) NOT NULL,
  `last_updated_on` char(36) DEFAULT NULL,
  `last_updated_by` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


##################################
ALTER TABLE `crov_inmobiliaria`.`abono_proyecto` 
ADD COLUMN `cantidad_pagada` DOUBLE NULL DEFAULT NULL AFTER `last_updated_by`;


ALTER TABLE `crov_inmobiliaria`.`abono_proyecto` 
CHANGE COLUMN `last_updated_on` `last_updated_on` DATE NULL DEFAULT NULL ,
CHANGE COLUMN `last_updated_by` `last_updated_by` CHAR(36) NULL DEFAULT NULL ;

ALTER TABLE `crov_inmobiliaria`.`lote` 
ADD COLUMN `estatus_activo` ENUM('ENABLED', 'DISABLED') NULL DEFAULT 'ENABLED' AFTER `fin_reserva`;

ALTER TABLE `crov_inmobiliaria`.`manzana` 
ADD COLUMN `estatus_activo` ENUM('ENABLED', 'DISABLED') NULL DEFAULT 'ENABLED' AFTER `last_updated_on`;

ALTER TABLE `crov_inmobiliaria`.`proyecto` 
ADD COLUMN `estatus_activo` ENUM('ENABLED', 'DISABLED') NULL DEFAULT 'ENABLED' AFTER `last_updated_on`;