.png)
// =====================================================
// [Project] 모아요 (ERD v1)
// [Source]
// - 공개/비공개: 프로필 전체 X, 이력(experiences) 개별 O
// - 프로필 기본정보: null 허용 X (필수 입력)
// - 이력 추가(3.1): '+' 시점에 draft 빈 row 선생성
// - 프로필 증빙(1.9): 검수 상태 사용 X, 개수 제한 3개(로직으로 제한)
// - 관심 태그: 사전 정의 태그 선택(유저 생성 X)
// [Naming] lowercase + snake_case
// [PK] id (bigint)
// =====================================================
// 1. 사용자
Table users {
id bigint [pk, increment]
email varchar [not null, unique, note: "로그인용 이메일(구글)"]
name varchar [not null, note: "사용자 실명/활동명"]
phone_number varchar [note: "연락처(선택)"]
created_at timestamp [not null, default: `now()`]
updated_at timestamp [not null, default: `now()`]
}
// 2. 프로필 (1:1)
// - 기본정보 null 허용 X: bio/university/major 필수
// - 전체 프로필 공개/비공개는 사용하지 않는 방향(카톡 답변)이라 is_public 제거
Table profiles {
id bigint [pk, increment]
user_id bigint [not null, unique, note: "users 1:1"]
image_url varchar [note: "프로필 대표 이미지(1장 교체형, 없으면 기본 이미지로 처리 가능)"]
bio text [not null, note: "자기소개(필수)"]
university varchar [not null, note: "대학명(필수)"]
major varchar [not null, note: "학과/부가정보(필수)"]
created_at timestamp [not null, default: `now()`]
updated_at timestamp [not null, default: `now()`]
}
// 2-1. 프로필 증빙 서류 (명세 1.9)
// - 검수 상태 사용 X -> status 제거
// - 개수 제한 3개는 DB 제약보단 서비스 로직에서 제한(예: profile_id 당 count <= 3)
Table profile_documents {
id bigint [pk, increment]
profile_id bigint [not null]
file_url varchar [not null]
file_name varchar
file_type varchar [note: "pdf/image 등"]
file_size bigint [note: "bytes"]
created_at timestamp [not null, default: `now()`]
indexes {
(profile_id) [name: "idx_profile_documents_profile_id"]
}
}
// 2-2. 프로필 커스텀 링크/추가정보 (명세 1.10)
Table profile_extra_fields {
id bigint [pk, increment]
profile_id bigint [not null]
label varchar [not null, note: "항목 이름 (예: github, portfolio)"]
value varchar [not null, note: "URL 또는 텍스트"]
value_type varchar [not null, default: 'link', note: "text/link"]
created_at timestamp [not null, default: `now()`]
indexes {
(profile_id) [name: "idx_profile_extra_fields_profile_id"]
}
}
// 3. 관심사 태그 (사전 정의 목록 선택)
// - 유저 생성 X: 태그 생성 API 불필요, seed로 채움
Table interest_tags {
id bigint [pk, increment]
name varchar [not null, unique, note: "태그명(사전 정의)"]
}
Table user_interest_tags {
id bigint [pk, increment]
user_id bigint [not null]
interest_tag_id bigint [not null]
created_at timestamp [not null, default: `now()`]
indexes {
(user_id, interest_tag_id) [unique, name: "uk_user_interest_tags"]
(user_id) [name: "idx_user_interest_tags_user_id"]
(interest_tag_id) [name: "idx_user_interest_tags_interest_tag_id"]
}
}
// 4. 이력(Experience)
// - '+' 누르면 draft 빈 row 선생성 -> 필수값은 draft 동안 null 허용해야 함
// - 공개 프로필 뷰에서는 is_public=false 이력만 제외하고 반환
Table experiences {
id bigint [pk, increment]
user_id bigint [not null]
// draft 상태에서 빈 row를 만들기 위해 null 허용 (published 전환 시 서비스 로직으로 필수값 검증)
activity_name varchar [note: "활동명(published 시 필수)"]
organization varchar [note: "주최기관"]
start_date date
end_date date
participation_type varchar [note: "참여형태(개인/팀 등)"]
job_role varchar [note: "직무 및 역할"]
description text [note: "회고 및 성과 요약"]
status varchar [not null, default: 'draft', note: "draft(임시)/published(발행)"]
is_public boolean [not null, default: true, note: "개별 이력 공개 여부"]
created_at timestamp [not null, default: `now()`]
updated_at timestamp [not null, default: `now()`]
indexes {
(user_id) [name: "idx_experiences_user_id"]
(status) [name: "idx_experiences_status"]
(is_public) [name: "idx_experiences_is_public"]
}
}
Table experience_files {
id bigint [pk, increment]
experience_id bigint [not null]
file_url varchar [not null]
file_name varchar
file_type varchar [note: "pdf/image 등"]
file_size bigint [note: "bytes"]
created_at timestamp [not null, default: `now()`]
indexes {
(experience_id) [name: "idx_experience_files_experience_id"]
}
}
// 링크 첨부(명세 4.4 대응)
Table experience_links {
id bigint [pk, increment]
experience_id bigint [not null]
url varchar [not null]
created_at timestamp [not null, default: `now()`]
indexes {
(experience_id) [name: "idx_experience_links_experience_id"]
}
}
// 5. 게시판(모집글)
Table job_categories {
id bigint [pk, increment]
name varchar [not null, unique, note: "직무명(필터용)"]
}
Table posts {
id bigint [pk, increment]
author_id bigint [not null, note: "작성자(users)"]
job_category_id bigint [not null, note: "직무 카테고리(job_categories)"]
title varchar [not null]
content text [not null]
recruit_count int [note: "모집 인원(선택)"]
deadline date [note: "null이면 상시모집"]
status varchar [not null, default: 'open', note: "open/closed"]
created_at timestamp [not null, default: `now()`]
updated_at timestamp [not null, default: `now()`]
indexes {
(job_category_id, created_at) [name: "idx_posts_category_created"]
(author_id) [name: "idx_posts_author_id"]
}
}
Table post_positions {
id bigint [pk, increment]
post_id bigint [not null]
position_name varchar [not null]
indexes {
(post_id) [name: "idx_post_positions_post_id"]
}
}
// 6. 쪽지/채팅
Table chat_rooms {
id bigint [pk, increment]
origin_post_id bigint [note: "어떤 모집글에서 시작된 대화인지(선택)"]
created_at timestamp [not null, default: `now()`]
indexes {
(origin_post_id) [name: "idx_chat_rooms_origin_post_id"]
}
}
Table chat_participants {
id bigint [pk, increment]
chat_room_id bigint [not null]
user_id bigint [not null]
last_read_message_id bigint [note: "안읽음 뱃지 계산용(마지막으로 읽은 메시지 id)"]
created_at timestamp [not null, default: `now()`]
indexes {
(chat_room_id, user_id) [unique, name: "uk_chat_room_user"]
(user_id) [name: "idx_chat_participants_user_id"]
}
}
Table messages {
id bigint [pk, increment]
chat_room_id bigint [not null]
sender_id bigint [not null]
content text [not null]
created_at timestamp [not null, default: `now()`]
indexes {
(chat_room_id, created_at) [name: "idx_messages_room_created"]
(sender_id) [name: "idx_messages_sender_id"]
}
}
// =====================================================
// Relationships (Foreign Keys)
// =====================================================
Ref: profiles.user_id > users.id
Ref: profile_documents.profile_id > profiles.id
Ref: profile_extra_fields.profile_id > profiles.id
Ref: user_interest_tags.user_id > users.id
Ref: user_interest_tags.interest_tag_id > interest_tags.id
Ref: experiences.user_id > users.id
Ref: experience_files.experience_id > experiences.id
Ref: experience_links.experience_id > experiences.id
Ref: posts.author_id > users.id
Ref: posts.job_category_id > job_categories.id
Ref: post_positions.post_id > posts.id
Ref: chat_rooms.origin_post_id > posts.id
Ref: chat_participants.chat_room_id > chat_rooms.id
Ref: chat_participants.user_id > users.id
Ref: messages.chat_room_id > chat_rooms.id
Ref: messages.sender_id > users.id