Skip to content

Commit

Permalink
Merge pull request #516 from ccxz84/feature/group_access
Browse files Browse the repository at this point in the history
[Feat] 그룹 참여코드 및 가입 신청 스키마에 대한 db 추가
  • Loading branch information
ccxz84 authored Jan 29, 2024
2 parents f6a8922 + 8110fe9 commit 8a93c4c
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 14 deletions.
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

0 comments on commit 8a93c4c

Please sign in to comment.