Files
twenty/server/src/database/migrations/20230718142504_add_attachments/migration.sql
Félix Malfait 10f7b08fdc Add attachments (#733)
* Add attachments v1

* Refacto

* Add Policy checks

* Fix tests

* Remove generated files from git

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-07-18 15:24:03 -07:00

25 lines
944 B
SQL

-- CreateEnum
CREATE TYPE "AttachmentType" AS ENUM ('Image', 'Audio', 'Video', 'TextDocument', 'Spreadsheet', 'Archive', 'Other');
-- CreateTable
CREATE TABLE "attachments" (
"id" TEXT NOT NULL,
"fullPath" TEXT NOT NULL,
"type" "AttachmentType" NOT NULL,
"name" TEXT NOT NULL,
"authorId" TEXT NOT NULL,
"activityId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
"deletedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "attachments_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "comment_threads"("id") ON DELETE RESTRICT ON UPDATE CASCADE;