/*
  Warnings:

  - You are about to drop the column `aniosAntiguedad` on the `Ocupante` table. All the data in the column will be lost.
  - You are about to drop the column `desdeAnio` on the `Ocupante` table. All the data in the column will be lost.
  - You are about to drop the column `direccionCompleta` on the `Ocupante` table. All the data in the column will be lost.
  - You are about to drop the column `estadoOcupacion` on the `Ocupante` table. All the data in the column will be lost.

*/
-- CreateEnum
CREATE TYPE "EstadoCivil" AS ENUM ('CASADO', 'VIUDO', 'DIVORCIADO', 'SOLTERO');

-- CreateEnum
CREATE TYPE "SituacionLaboral" AS ENUM ('INDEPENDIENTE', 'DEPENDIENTE', 'PENSIONADO', 'JUBILADO', 'CESANTE');

-- CreateEnum
CREATE TYPE "ParentescoOcupante" AS ENUM ('HIJO', 'CONYUGE', 'ESPOSO', 'TIO', 'SOBRINO', 'NIETO', 'OTRO');

-- AlterEnum
ALTER TYPE "EstadoFicha" ADD VALUE 'EN_REVISION';

-- DropIndex
DROP INDEX "Ocupante_estadoOcupacion_idx";

-- AlterTable
ALTER TABLE "Ocupante" DROP COLUMN "aniosAntiguedad",
DROP COLUMN "desdeAnio",
DROP COLUMN "direccionCompleta",
DROP COLUMN "estadoOcupacion",
ADD COLUMN     "anioLlegadaSector" INTEGER,
ADD COLUMN     "cantidadPersonasLote" INTEGER,
ADD COLUMN     "correoElectronico" TEXT,
ADD COLUMN     "estadoCivil" "EstadoCivil",
ADD COLUMN     "fechaNacimiento" TIMESTAMP(3),
ADD COLUMN     "situacionLaboral" "SituacionLaboral";

-- DropEnum
DROP TYPE "EstadoOcupacion";

-- CreateTable
CREATE TABLE "OcupanteActualLote" (
    "id" TEXT NOT NULL,
    "fichaId" TEXT NOT NULL,
    "nombreCompleto" TEXT NOT NULL,
    "rut" TEXT,
    "edad" INTEGER,
    "parentesco" "ParentescoOcupante" NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "deletedAt" TIMESTAMP(3),

    CONSTRAINT "OcupanteActualLote_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "OcupanteActualLote_fichaId_idx" ON "OcupanteActualLote"("fichaId");

-- CreateIndex
CREATE INDEX "OcupanteActualLote_rut_idx" ON "OcupanteActualLote"("rut");

-- CreateIndex
CREATE INDEX "OcupanteActualLote_deletedAt_idx" ON "OcupanteActualLote"("deletedAt");

-- AddForeignKey
ALTER TABLE "OcupanteActualLote" ADD CONSTRAINT "OcupanteActualLote_fichaId_fkey" FOREIGN KEY ("fichaId") REFERENCES "EmpadronamientoFicha"("id") ON DELETE CASCADE ON UPDATE CASCADE;
