first commit
This commit is contained in:
commit
c9fb67e751
423 files changed
+53287
No files matched your search
@@ -0,0 +1,58 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "TipoAtendimento" AS ENUM ('INICIAL', 'RETORNO', 'ENCAMINHAMENTO', 'ORIENTACAO', 'ACORDO', 'OUTROS');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "atendimentos" (
|
||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
"protocolo" TEXT NOT NULL,
|
||||
"clienteId" UUID NOT NULL,
|
||||
"processoId" UUID,
|
||||
"tipo" "TipoAtendimento" NOT NULL DEFAULT 'INICIAL',
|
||||
"titulo" VARCHAR(200) NOT NULL,
|
||||
"conteudo" TEXT NOT NULL,
|
||||
"dataAtendimento" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"dataCriacao" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"usuarioId" UUID NOT NULL,
|
||||
|
||||
CONSTRAINT "atendimentos_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "anexos_atendimento" (
|
||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
"atendimentoId" UUID NOT NULL,
|
||||
"nome" VARCHAR(200) NOT NULL,
|
||||
"tipo" VARCHAR(50) NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"armazenamento" VARCHAR(20) NOT NULL DEFAULT 'NEXTCLOUD',
|
||||
"dataCriacao" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "anexos_atendimento_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "atendimentos_protocolo_key" ON "atendimentos"("protocolo");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "atendimentos_clienteId_idx" ON "atendimentos"("clienteId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "atendimentos_processoId_idx" ON "atendimentos"("processoId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "atendimentos_protocolo_idx" ON "atendimentos"("protocolo");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "anexos_atendimento_atendimentoId_idx" ON "anexos_atendimento"("atendimentoId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "atendimentos" ADD CONSTRAINT "atendimentos_clienteId_fkey" FOREIGN KEY ("clienteId") REFERENCES "clientes"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "atendimentos" ADD CONSTRAINT "atendimentos_processoId_fkey" FOREIGN KEY ("processoId") REFERENCES "Processo"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "atendimentos" ADD CONSTRAINT "atendimentos_usuarioId_fkey" FOREIGN KEY ("usuarioId") REFERENCES "usuarios"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "anexos_atendimento" ADD CONSTRAINT "anexos_atendimento_atendimentoId_fkey" FOREIGN KEY ("atendimentoId") REFERENCES "atendimentos"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Reference in new issue
Block a user