Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] 그룹 참여코드 및 가입 신청 스키마에 대한 db 추가 #516

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Warnings:

- You are about to alter the column `date` on the `Mogaco` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `deleted_at` on the `Mogaco` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- Added the required column `groupType` to the `Group` table without a default value. This is not possible if the table is not empty.
- Added the required column `group_owner` to the `Group` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE `Group` ADD COLUMN `groupType` TINYINT NOT NULL,
ADD COLUMN `group_owner` BIGINT NOT NULL;

-- AlterTable
ALTER TABLE `Mogaco` MODIFY `date` DATETIME NOT NULL,
MODIFY `deleted_at` DATETIME NULL;

-- CreateTable
CREATE TABLE `GroupAccessCode` (
`accessCode` VARCHAR(256) NOT NULL,
`groupId` BIGINT NOT NULL,

PRIMARY KEY (`accessCode`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `MembershipRequest` (
`id` BIGINT NOT NULL,
`group_id` BIGINT NOT NULL,
`user_id` BIGINT NOT NULL,
`status` TINYINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME(3) NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `Group` ADD CONSTRAINT `Group_group_owner_fkey` FOREIGN KEY (`group_owner`) REFERENCES `Member`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `GroupAccessCode` ADD CONSTRAINT `GroupAccessCode_groupId_fkey` FOREIGN KEY (`groupId`) REFERENCES `Group`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `MembershipRequest` ADD CONSTRAINT `MembershipRequest_group_id_fkey` FOREIGN KEY (`group_id`) REFERENCES `Group`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `MembershipRequest` ADD CONSTRAINT `MembershipRequest_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Member`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
60 changes: 46 additions & 14 deletions app/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ datasource db {
}

model Member {
id BigInt @id @default(autoincrement()) @db.BigInt
providerId String @unique @map("provider_id") @db.VarChar(191)
email String @unique @db.VarChar(191)
nickname String @db.VarChar(191)
profilePicture String @map("profile_picture") @db.VarChar(191)
socialType String @map("social_type") @db.VarChar(191)
createdAt DateTime @default(now()) @map("created_at")
users GroupToUser[]
members Participant[]
mogacos Mogaco[]
id BigInt @id @default(autoincrement()) @db.BigInt
providerId String @unique @map("provider_id") @db.VarChar(191)
email String @unique @db.VarChar(191)
nickname String @db.VarChar(191)
profilePicture String @map("profile_picture") @db.VarChar(191)
socialType String @map("social_type") @db.VarChar(191)
createdAt DateTime @default(now()) @map("created_at")
users GroupToUser[]
members Participant[]
mogacos Mogaco[]
groupOwner Group[]
membershipRequests MembershipRequest[]

@@map("Member")
}
Expand Down Expand Up @@ -49,14 +51,44 @@ model Mogaco {
}

model Group {
id BigInt @id @default(autoincrement()) @db.BigInt
title String @db.VarChar(191)
groups GroupToUser[]
mogacos Mogaco[]
id BigInt @id @default(autoincrement()) @db.BigInt
title String @db.VarChar(191)
groupOwner BigInt @map("group_owner") @db.BigInt
groupType Int @db.TinyInt

groups GroupToUser[]
mogacos Mogaco[]
groupAccessCodes GroupAccessCode[]
membershipRequests MembershipRequest[]

group_owner Member @relation(fields: [groupOwner], references: [id])

@@map("Group")
}

model GroupAccessCode {
accessCode String @id @db.VarChar(256)
groupId BigInt @db.BigInt

groupAccessCodes Group @relation(fields: [groupId], references: [id])

@@map("GroupAccessCode")
}

model MembershipRequest {
id BigInt @id @db.BigInt
groupId BigInt @map("group_id") @db.BigInt
userId BigInt @map("user_id") @db.BigInt
status Int @db.TinyInt
createdAt DateTime @map("created_at") @db.DateTime
updatedAt DateTime? @updatedAt() @map("updated_at")

group Group @relation(fields: [groupId], references: [id])
user Member @relation(fields: [userId], references: [id])

@@map("MembershipRequest")
}

model GroupToUser {
groupId BigInt @map("group_id") @db.BigInt
userId BigInt @map("user_id") @db.BigInt
Expand Down