first commit

This commit is contained in:
rodrigo committed 2025-04-10 23:07:21 -03:00
commit c9fb67e751
423 files changed
+53287

No files matched your search

@@ -0,0 +1,379 @@
/*
Warnings:
- The primary key for the `alertas` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `alertas` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `clientes` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `clientes` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `custas_processuais` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `custas_processuais` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The `status` column on the `custas_processuais` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `filhos` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `filhos` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `honorarios` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `parcelas` on the `honorarios` table. All the data in the column will be lost.
- You are about to drop the column `valor` on the `honorarios` table. All the data in the column will be lost.
- The `id` column on the `honorarios` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The `status` column on the `honorarios` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `modelos_documentos` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `modelos_documentos` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `orgaos_julgadores` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `orgaos_julgadores` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `usuarios` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `usuarios` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- You are about to drop the `audiencias` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `diligencias` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `documentos` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `movimentacoes` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `movimentacoes_tribunal` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `partes_processo` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `processos` table. If the table is not empty, all the data it contains will be lost.
- Changed the type of `usuarioId` on the `alertas` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
- Added the required column `descricao` to the `custas_processuais` table without a default value. This is not possible if the table is not empty.
- Changed the type of `processoId` on the `custas_processuais` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
- Changed the type of `tipo` on the `custas_processuais` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
- Changed the type of `clienteId` on the `filhos` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
- Changed the type of `processoId` on the `honorarios` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- CreateEnum
CREATE TYPE "TipoCustaProcessual" AS ENUM ('INICIAL', 'RECURSO', 'PERICIA', 'OFICIAL_JUSTICA', 'CARTA_PRECATORIA', 'DEPOSITO_JUDICIAL', 'CERTIDAO', 'DIGITALIZACAO', 'CONDUTOR', 'CORREIOS', 'CARTORIO', 'OUTROS');
-- CreateEnum
CREATE TYPE "StatusPagamento" AS ENUM ('PENDENTE', 'PARCIALMENTE_PAGO', 'PAGO', 'VENCIDO', 'CANCELADO');
-- CreateEnum
CREATE TYPE "FormaPagamento" AS ENUM ('VISTA', 'PARCELADO', 'ENTRADA_MAIS_PARCELAS', 'PERCENTUAL_CAUSA', 'PERCENTUAL_EXITO');
-- DropForeignKey
ALTER TABLE "audiencias" DROP CONSTRAINT "audiencias_processoId_fkey";
-- DropForeignKey
ALTER TABLE "custas_processuais" DROP CONSTRAINT "custas_processuais_processoId_fkey";
-- DropForeignKey
ALTER TABLE "diligencias" DROP CONSTRAINT "diligencias_processoId_fkey";
-- DropForeignKey
ALTER TABLE "documentos" DROP CONSTRAINT "documentos_processoId_fkey";
-- DropForeignKey
ALTER TABLE "filhos" DROP CONSTRAINT "filhos_clienteId_fkey";
-- DropForeignKey
ALTER TABLE "honorarios" DROP CONSTRAINT "honorarios_processoId_fkey";
-- DropForeignKey
ALTER TABLE "movimentacoes" DROP CONSTRAINT "movimentacoes_processoId_fkey";
-- DropForeignKey
ALTER TABLE "movimentacoes_tribunal" DROP CONSTRAINT "movimentacoes_tribunal_processoId_fkey";
-- DropForeignKey
ALTER TABLE "partes_processo" DROP CONSTRAINT "partes_processo_clienteId_fkey";
-- DropForeignKey
ALTER TABLE "partes_processo" DROP CONSTRAINT "partes_processo_processoId_fkey";
-- DropForeignKey
ALTER TABLE "processos" DROP CONSTRAINT "processos_clienteId_fkey";
-- DropForeignKey
ALTER TABLE "processos" DROP CONSTRAINT "processos_orgaoJulgadorId_fkey";
-- AlterTable
ALTER TABLE "alertas" DROP CONSTRAINT "alertas_pkey",
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
DROP COLUMN "usuarioId",
ADD COLUMN "usuarioId" UUID NOT NULL,
ADD CONSTRAINT "alertas_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "clientes" DROP CONSTRAINT "clientes_pkey",
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "clientes_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "custas_processuais" DROP CONSTRAINT "custas_processuais_pkey",
ADD COLUMN "descricao" VARCHAR(200) NOT NULL,
ADD COLUMN "numeroParcelas" INTEGER NOT NULL DEFAULT 1,
ADD COLUMN "observacoes" TEXT,
ADD COLUMN "parcelaAtual" INTEGER NOT NULL DEFAULT 1,
ADD COLUMN "percentual" DECIMAL(5,2),
ADD COLUMN "vencimento" TIMESTAMP(3),
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
DROP COLUMN "processoId",
ADD COLUMN "processoId" UUID NOT NULL,
DROP COLUMN "tipo",
ADD COLUMN "tipo" "TipoCustaProcessual" NOT NULL,
DROP COLUMN "status",
ADD COLUMN "status" "StatusPagamento" NOT NULL DEFAULT 'PENDENTE',
ADD CONSTRAINT "custas_processuais_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "filhos" DROP CONSTRAINT "filhos_pkey",
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
DROP COLUMN "clienteId",
ADD COLUMN "clienteId" UUID NOT NULL,
ADD CONSTRAINT "filhos_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "honorarios" DROP CONSTRAINT "honorarios_pkey",
DROP COLUMN "parcelas",
DROP COLUMN "valor",
ADD COLUMN "dataContrato" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "diaVencimento" INTEGER NOT NULL DEFAULT 10,
ADD COLUMN "formaPagamento" "FormaPagamento" NOT NULL DEFAULT 'VISTA',
ADD COLUMN "numeroParcelas" INTEGER NOT NULL DEFAULT 1,
ADD COLUMN "percentualCausa" DECIMAL(5,2),
ADD COLUMN "percentualExito" DECIMAL(5,2),
ADD COLUMN "valorEntrada" DECIMAL(10,2),
ADD COLUMN "valorFixo" DECIMAL(10,2),
ADD COLUMN "valorParcela" DECIMAL(10,2),
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
DROP COLUMN "processoId",
ADD COLUMN "processoId" UUID NOT NULL,
DROP COLUMN "status",
ADD COLUMN "status" "StatusPagamento" NOT NULL DEFAULT 'PENDENTE',
ADD CONSTRAINT "honorarios_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "modelos_documentos" DROP CONSTRAINT "modelos_documentos_pkey",
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "modelos_documentos_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "orgaos_julgadores" DROP CONSTRAINT "orgaos_julgadores_pkey",
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "orgaos_julgadores_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "usuarios" DROP CONSTRAINT "usuarios_pkey",
DROP COLUMN "id",
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
ADD CONSTRAINT "usuarios_pkey" PRIMARY KEY ("id");
-- DropTable
DROP TABLE "audiencias";
-- DropTable
DROP TABLE "diligencias";
-- DropTable
DROP TABLE "documentos";
-- DropTable
DROP TABLE "movimentacoes";
-- DropTable
DROP TABLE "movimentacoes_tribunal";
-- DropTable
DROP TABLE "partes_processo";
-- DropTable
DROP TABLE "processos";
-- CreateTable
CREATE TABLE "ParteProcesso" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"processoId" UUID NOT NULL,
"clienteId" UUID,
"tipo" VARCHAR(20) NOT NULL,
"nome" VARCHAR(200) NOT NULL,
"cpfCnpj" VARCHAR(18),
"principal" BOOLEAN NOT NULL DEFAULT false,
"observacoes" TEXT,
"dataCriacao" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "ParteProcesso_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Processo" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"numero" TEXT NOT NULL,
"natureza" TEXT NOT NULL,
"valorCausa" DECIMAL(15,2),
"orgaoJulgador" VARCHAR(100) NOT NULL,
"orgaoOrigem" VARCHAR(100),
"nomeContraparte" VARCHAR(100) NOT NULL,
"status" VARCHAR(20) NOT NULL DEFAULT 'INICIAL',
"statusAtividade" VARCHAR(20) NOT NULL DEFAULT 'ATIVO',
"dataCriacao" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"dataAtualizacao" TIMESTAMP NOT NULL,
"clienteId" UUID NOT NULL,
"tipoParteCliente" VARCHAR(20) NOT NULL,
"orgaoJulgadorId" UUID,
CONSTRAINT "Processo_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Audiencia" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"processoId" UUID NOT NULL,
"tipo" VARCHAR(50) NOT NULL,
"data" TIMESTAMP NOT NULL,
"local" VARCHAR(200) NOT NULL,
"modalidade" VARCHAR(20) NOT NULL DEFAULT 'PRESENCIAL',
"status" VARCHAR(20) NOT NULL DEFAULT 'AGENDADA',
"linkVirtual" TEXT,
"observacoes" TEXT,
"dataCriacao" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Audiencia_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Diligencia" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"processoId" UUID NOT NULL,
"tipo" VARCHAR(50) NOT NULL,
"descricao" TEXT NOT NULL,
"dataLimite" TIMESTAMP NOT NULL,
"status" VARCHAR(20) NOT NULL DEFAULT 'PENDENTE',
"responsavel" VARCHAR(100),
"observacoes" TEXT,
"dataCriacao" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Diligencia_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Movimentacao" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"processoId" UUID NOT NULL,
"data" TIMESTAMP NOT NULL,
"descricao" TEXT NOT NULL,
"tipo" VARCHAR(50) NOT NULL,
"documento" TEXT,
"dataCriacao" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Movimentacao_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Documento" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"processoId" UUID NOT NULL,
"nome" VARCHAR(200) NOT NULL,
"tipo" VARCHAR(50) NOT NULL,
"url" TEXT NOT NULL,
"dataCriacao" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Documento_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "parcelas_honorario" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"honorarioId" UUID NOT NULL,
"numeroParcela" INTEGER NOT NULL,
"valor" DECIMAL(10,2) NOT NULL,
"valorPago" DECIMAL(10,2),
"vencimento" TIMESTAMP(3) NOT NULL,
"dataPagamento" TIMESTAMP(3),
"status" "StatusPagamento" NOT NULL DEFAULT 'PENDENTE',
"comprovante" TEXT,
"observacoes" TEXT,
CONSTRAINT "parcelas_honorario_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "MovimentacaoTribunal" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"processoId" UUID NOT NULL,
"tribunal" VARCHAR(50) NOT NULL,
"data" TIMESTAMP(3) NOT NULL,
"descricao" TEXT NOT NULL,
"dataCriacao" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MovimentacaoTribunal_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "ParteProcesso_processoId_idx" ON "ParteProcesso"("processoId");
-- CreateIndex
CREATE INDEX "ParteProcesso_clienteId_idx" ON "ParteProcesso"("clienteId");
-- CreateIndex
CREATE UNIQUE INDEX "Processo_numero_key" ON "Processo"("numero");
-- CreateIndex
CREATE INDEX "Processo_clienteId_idx" ON "Processo"("clienteId");
-- CreateIndex
CREATE INDEX "Processo_orgaoJulgadorId_idx" ON "Processo"("orgaoJulgadorId");
-- CreateIndex
CREATE INDEX "Audiencia_processoId_idx" ON "Audiencia"("processoId");
-- CreateIndex
CREATE INDEX "Diligencia_processoId_idx" ON "Diligencia"("processoId");
-- CreateIndex
CREATE INDEX "Movimentacao_processoId_idx" ON "Movimentacao"("processoId");
-- CreateIndex
CREATE INDEX "Documento_processoId_idx" ON "Documento"("processoId");
-- CreateIndex
CREATE INDEX "parcelas_honorario_honorarioId_idx" ON "parcelas_honorario"("honorarioId");
-- CreateIndex
CREATE INDEX "MovimentacaoTribunal_processoId_idx" ON "MovimentacaoTribunal"("processoId");
-- CreateIndex
CREATE INDEX "custas_processuais_processoId_idx" ON "custas_processuais"("processoId");
-- CreateIndex
CREATE INDEX "honorarios_processoId_idx" ON "honorarios"("processoId");
-- AddForeignKey
ALTER TABLE "filhos" ADD CONSTRAINT "filhos_clienteId_fkey" FOREIGN KEY ("clienteId") REFERENCES "clientes"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ParteProcesso" ADD CONSTRAINT "ParteProcesso_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ParteProcesso" ADD CONSTRAINT "ParteProcesso_clienteId_fkey" FOREIGN KEY ("clienteId") REFERENCES "clientes"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Processo" ADD CONSTRAINT "Processo_clienteId_fkey" FOREIGN KEY ("clienteId") REFERENCES "clientes"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Processo" ADD CONSTRAINT "Processo_orgaoJulgadorId_fkey" FOREIGN KEY ("orgaoJulgadorId") REFERENCES "orgaos_julgadores"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Audiencia" ADD CONSTRAINT "Audiencia_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Diligencia" ADD CONSTRAINT "Diligencia_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Movimentacao" ADD CONSTRAINT "Movimentacao_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Documento" ADD CONSTRAINT "Documento_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "custas_processuais" ADD CONSTRAINT "custas_processuais_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "honorarios" ADD CONSTRAINT "honorarios_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "parcelas_honorario" ADD CONSTRAINT "parcelas_honorario_honorarioId_fkey" FOREIGN KEY ("honorarioId") REFERENCES "honorarios"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "MovimentacaoTribunal" ADD CONSTRAINT "MovimentacaoTribunal_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE RESTRICT ON UPDATE CASCADE;