Files
2025-04-10 23:07:21 -03:00

45 lines
1.4 KiB
SQL

/*
Warnings:
- You are about to drop the `anexos` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `anexos_atendimento` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "anexos" DROP CONSTRAINT "anexos_tarefaId_fkey";
-- DropForeignKey
ALTER TABLE "anexos_atendimento" DROP CONSTRAINT "anexos_atendimento_atendimentoId_fkey";
-- DropTable
DROP TABLE "anexos";
-- DropTable
DROP TABLE "anexos_atendimento";
-- CreateTable
CREATE TABLE "Anexo" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"nome" TEXT NOT NULL,
"url" TEXT NOT NULL,
"tipo" TEXT NOT NULL,
"tamanho" INTEGER NOT NULL,
"atendimentoId" UUID,
"tarefaId" UUID,
"criadoEm" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Anexo_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Anexo_atendimentoId_idx" ON "Anexo"("atendimentoId");
-- CreateIndex
CREATE INDEX "Anexo_tarefaId_idx" ON "Anexo"("tarefaId");
-- AddForeignKey
ALTER TABLE "Anexo" ADD CONSTRAINT "Anexo_atendimentoId_fkey" FOREIGN KEY ("atendimentoId") REFERENCES "atendimentos"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Anexo" ADD CONSTRAINT "Anexo_tarefaId_fkey" FOREIGN KEY ("tarefaId") REFERENCES "tarefas"("id") ON DELETE SET NULL ON UPDATE CASCADE;