Skip to content

Commit

Permalink
課題と参加者の中間テーブルを作成 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kbot committed Sep 3, 2023
1 parent 374c749 commit ecf0b84
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "task_progress" (
"id" VARCHAR(255) NOT NULL,
"status" INTEGER NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"task_id" TEXT NOT NULL,
"participant_id" TEXT NOT NULL,

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

-- AddForeignKey
ALTER TABLE "task_progress" ADD CONSTRAINT "task_progress_task_id_fkey" FOREIGN KEY ("task_id") REFERENCES "tasks"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "task_progress" ADD CONSTRAINT "task_progress_participant_id_fkey" FOREIGN KEY ("participant_id") REFERENCES "participants"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
41 changes: 28 additions & 13 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,40 @@ model Pair {
}

model Participant {
id String @id @db.VarChar(255)
name String @db.VarChar(255)
email String @db.VarChar(255)
id String @id @db.VarChar(255)
name String @db.VarChar(255)
email String @db.VarChar(255)
status Int
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
teamId String @map("team_id")
Team Team @relation(fields: [teamId], references: [id])
pairId String @map("pair_id")
Pair Pair @relation(fields: [pairId], references: [id])
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
teamId String @map("team_id")
Team Team @relation(fields: [teamId], references: [id])
pairId String @map("pair_id")
Pair Pair @relation(fields: [pairId], references: [id])
Tasks TaskProgress[]
@@map("participants")
}

model Task {
id String @id @db.VarChar(255)
name String @db.VarChar(255)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
id String @id @db.VarChar(255)
name String @db.VarChar(255)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
Participants TaskProgress[]
@@map("tasks")
}

model TaskProgress {
id String @id @db.VarChar(255)
status Int
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
taskId String @map("task_id")
Task Task @relation(fields: [taskId], references: [id])
participantId String @map("participant_id")
Participant Participant @relation(fields: [participantId], references: [id])
@@map("task_progress")
}

0 comments on commit ecf0b84

Please sign in to comment.