Skip to content

Commit

Permalink
Merge pull request #8 from gsainfoteam/2-hhj
Browse files Browse the repository at this point in the history
여러 명의 교수가 하나의 과목 강의 경우를 위한 일대다 관계
  • Loading branch information
gurwoghd authored Jul 11, 2024
2 parents 87ca725 + b7f5cab commit 0504adb
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 200 deletions.
13 changes: 4 additions & 9 deletions erd/database.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ Table Lecture {
name varchar
}

Table LectureProfessor {
Table LectureSection {
id int [pk, increment]
lecture_id int [ref: > Lecture.id]
professor_id int [ref: > Professor.id]

Indexes {
(lecture_id, professor_id) [pk]
}
}

Table Record {
Expand All @@ -72,6 +68,5 @@ Table Record {
created_at datetime

user_uuid uuid [ref: > User.uuid]
lecture_id int [ref: > Lecture.id]
professor_id int [ref: > Professor.id]
}
section_id int [ref: > LectureSection.id]
}
82 changes: 41 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@nestjs/core": "^10.0.0",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.3.1",
"@nestjs/swagger": "^7.4.0",
"@prisma/client": "^5.15.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
Expand Down Expand Up @@ -55,8 +55,8 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"prisma": "^5.15.1",
"prettier": "^3.3.2",
"prisma": "^5.16.1",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions prisma/migrations/20240711075735_add_record_like/migration.sql

This file was deleted.

80 changes: 80 additions & 0 deletions prisma/migrations/20240711082736_lecture_section/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
Warnings:
- You are about to drop the column `lecture_name` on the `lecture` table. All the data in the column will be lost.
- You are about to drop the column `lecture_id` on the `record` table. All the data in the column will be lost.
- You are about to drop the column `professor_id` on the `record` table. All the data in the column will be lost.
- You are about to drop the `lecture_professor` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `name` to the `lecture` table without a default value. This is not possible if the table is not empty.
- Added the required column `section_id` to the `record` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "lecture_professor" DROP CONSTRAINT "lecture_professor_lecture_id_fkey";

-- DropForeignKey
ALTER TABLE "lecture_professor" DROP CONSTRAINT "lecture_professor_professor_id_fkey";

-- DropForeignKey
ALTER TABLE "record" DROP CONSTRAINT "record_lecture_id_professor_id_fkey";

-- AlterTable
ALTER TABLE "lecture" DROP COLUMN "lecture_name",
ADD COLUMN "name" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "record" DROP COLUMN "lecture_id",
DROP COLUMN "professor_id",
ADD COLUMN "section_id" INTEGER NOT NULL;

-- DropTable
DROP TABLE "lecture_professor";

-- CreateTable
CREATE TABLE "lecture_section" (
"id" SERIAL NOT NULL,
"lecture_id" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "record_like" (
"id" SERIAL NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted_at" TIMESTAMP(3),
"user_uuid" UUID NOT NULL,
"record_id" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "_LectureSectionToProfessor" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "_LectureSectionToProfessor_AB_unique" ON "_LectureSectionToProfessor"("A", "B");

-- CreateIndex
CREATE INDEX "_LectureSectionToProfessor_B_index" ON "_LectureSectionToProfessor"("B");

-- AddForeignKey
ALTER TABLE "lecture_section" ADD CONSTRAINT "lecture_section_lecture_id_fkey" FOREIGN KEY ("lecture_id") REFERENCES "lecture"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "record" ADD CONSTRAINT "record_section_id_fkey" FOREIGN KEY ("section_id") REFERENCES "lecture_section"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "record_like" ADD CONSTRAINT "record_like_user_uuid_fkey" FOREIGN KEY ("user_uuid") REFERENCES "user"("uuid") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "record_like" ADD CONSTRAINT "record_like_record_id_fkey" FOREIGN KEY ("record_id") REFERENCES "record"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_LectureSectionToProfessor" ADD CONSTRAINT "_LectureSectionToProfessor_A_fkey" FOREIGN KEY ("A") REFERENCES "lecture_section"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_LectureSectionToProfessor" ADD CONSTRAINT "_LectureSectionToProfessor_B_fkey" FOREIGN KEY ("B") REFERENCES "professor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Loading

0 comments on commit 0504adb

Please sign in to comment.