Skip to content

Commit

Permalink
added base schema
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueweiand committed Oct 31, 2023
1 parent dd7f84c commit f031173
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- CreateTable
CREATE TABLE "question" (
"id" TEXT NOT NULL,
"content" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"author_id" TEXT NOT NULL,

CONSTRAINT "question_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "answers" (
"id" TEXT NOT NULL,
"content" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"question_id" TEXT NOT NULL,
"correct" BOOLEAN NOT NULL DEFAULT false,

CONSTRAINT "answers_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "question" ADD CONSTRAINT "question_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "answers" ADD CONSTRAINT "answers_question_id_fkey" FOREIGN KEY ("question_id") REFERENCES "question"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
28 changes: 28 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,33 @@ model User {
username String @unique
password String
questions Question[]
@@map("users")
}

model Question {
id String @id @default(uuid())
content String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
authorId String @map("author_id")
author User @relation(fields: [authorId], references: [id])
answers Answer[]
@@map("question")
}

model Answer {
id String @id @default(uuid())
content String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
questionId String @map("question_id")
correct Boolean @default(false)
question Question @relation(fields: [questionId], references: [id])
@@map("answers")
}
9 changes: 0 additions & 9 deletions prisma/vitest-environment-prisma/package.json

This file was deleted.

42 changes: 0 additions & 42 deletions prisma/vitest-environment-prisma/prisma-test-environment.ts

This file was deleted.

0 comments on commit f031173

Please sign in to comment.