26 lines
877 B
SQL
26 lines
877 B
SQL
-- CreateTable
|
|
CREATE TABLE "comment" (
|
|
"id" TEXT NOT NULL,
|
|
"content" TEXT NOT NULL,
|
|
"issueId" INTEGER NOT NULL,
|
|
"authorId" TEXT,
|
|
"editedAt" TIMESTAMPTZ(3),
|
|
"deletedAt" TIMESTAMPTZ(3),
|
|
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMPTZ(3) NOT NULL,
|
|
|
|
CONSTRAINT "comment_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "comment_issueId_createdAt_idx" ON "comment"("issueId", "createdAt");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "comment_authorId_idx" ON "comment"("authorId");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "comment" ADD CONSTRAINT "comment_issueId_fkey" FOREIGN KEY ("issueId") REFERENCES "issue"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "comment" ADD CONSTRAINT "comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|