Skip to content

Commit

Permalink
Merge pull request #1346 from mino323/master
Browse files Browse the repository at this point in the history
adds_module_migration
  • Loading branch information
anso3 authored Jan 28, 2022
2 parents e34a69f + 3621b8f commit d62e3a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions prisma/migrations/20220124135034_added_module/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- CreateTable
CREATE TABLE "modules" (
"id" SERIAL NOT NULL,
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(6) NOT NULL,
"authorId" INTEGER NOT NULL,
"lessonId" INTEGER NOT NULL,
"name" VARCHAR(255) NOT NULL,
"content" TEXT NOT NULL,

PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "modules" ADD FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "modules" ADD FOREIGN KEY ("lessonId") REFERENCES "lessons"("id") ON DELETE CASCADE ON UPDATE CASCADE;
16 changes: 16 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ model Lesson {
starLesson Star[] @relation("starLesson")
submissions Submission[]
userLessons UserLesson[]
modules Module[]
@@map("lessons")
}
Expand Down Expand Up @@ -151,6 +152,21 @@ model User {
submissions Submission[] @relation("userSubmissions")
userLessons UserLesson[]
comments Comment[]
modules Module[]
@@map("users")
}

model Module {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
author User @relation(fields: [authorId], references: [id])
authorId Int
lesson Lesson @relation(fields: [lessonId], references: [id])
lessonId Int
name String @db.VarChar(255)
content String
@@map("modules")
}

1 comment on commit d62e3a9

@vercel
Copy link

@vercel vercel bot commented on d62e3a9 Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.