Files
ai-dev-portal/schema.sql
2620227 84ce8567e7 feat(profile): 프로필에 '한줄 소개' 추가 — 본인만 인라인 편집
- users.bio 컬럼(멱등) + db.setBio / getUserProfile 조회 포함
- POST /profile/bio (본인만, fetch JSON / 폼 POST 폴백)
- 프로필 히어로: 이름·사번 한 줄로 합치고 한줄 소개를 3줄째로 배치
- 본인은 연필 버튼으로 인라인 편집(저장/취소·Esc), 최대 80자
- word-break: keep-all 로 한글 단어 중간 잘림 방지

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 13:43:49 +09:00

65 lines
3.2 KiB
SQL

-- AI DEV portal 스키마 (search_path=portal). 멱등.
-- 직원 식별자는 사번(Keycloak preferred_username). 표시 이름은 name.
CREATE TABLE IF NOT EXISTS users (
sabun text PRIMARY KEY, -- 사번 (Keycloak preferred_username)
name text NOT NULL,
email text,
avatar_seed text, -- 아바타 색/이니셜용(미업로드 시 identicon 시드)
created_at timestamptz NOT NULL DEFAULT now(),
last_login timestamptz
);
-- 업로드한 프로필 사진(1:1 크롭·256px webp 등, 브라우저에서 축소). 없으면 identicon 폴백.
ALTER TABLE users ADD COLUMN IF NOT EXISTS avatar bytea;
ALTER TABLE users ADD COLUMN IF NOT EXISTS avatar_mime text;
ALTER TABLE users ADD COLUMN IF NOT EXISTS avatar_updated_at timestamptz;
-- 한줄 소개(프로필에 표시). 본인만 편집.
ALTER TABLE users ADD COLUMN IF NOT EXISTS bio text DEFAULT '';
-- 공유 프로젝트 (직원이 만든 앱/repo 를 포털에 공유)
CREATE TABLE IF NOT EXISTS projects (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
owner_sabun text NOT NULL REFERENCES users(sabun),
title text NOT NULL,
description text DEFAULT '',
repo_url text DEFAULT '', -- Gitea repo
app_url text DEFAULT '', -- 배포된 앱 (*.apps.bokdev.in)
tags text DEFAULT '', -- 콤마 구분
is_public boolean NOT NULL DEFAULT true, -- 공개(피드 노출) / 비공개(나만)
lang text DEFAULT '', -- 대표 언어(태그에서 추론, 카드 언어 점)
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
-- 기존 배포 DB 대비 멱등 컬럼 추가
ALTER TABLE projects ADD COLUMN IF NOT EXISTS is_public boolean NOT NULL DEFAULT true;
ALTER TABLE projects ADD COLUMN IF NOT EXISTS lang text DEFAULT '';
CREATE INDEX IF NOT EXISTS idx_projects_created ON projects(created_at DESC);
-- 코멘트 (parent_id 가 null 이면 최상위, 있으면 대댓글 — 1뎁스만 허용: 앱에서 검증)
CREATE TABLE IF NOT EXISTS comments (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
project_id bigint NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
author_sabun text NOT NULL REFERENCES users(sabun),
parent_id bigint REFERENCES comments(id) ON DELETE CASCADE,
body text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE comments ADD COLUMN IF NOT EXISTS parent_id bigint REFERENCES comments(id) ON DELETE CASCADE;
CREATE INDEX IF NOT EXISTS idx_comments_project ON comments(project_id, created_at);
-- 좋아요(❤️) — 1인 1좋아요
CREATE TABLE IF NOT EXISTS hearts (
project_id bigint NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
sabun text NOT NULL REFERENCES users(sabun),
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (project_id, sabun)
);
-- 즐겨찾기(⭐ Star) — 1인 1즐겨찾기
CREATE TABLE IF NOT EXISTS stars (
project_id bigint NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
sabun text NOT NULL REFERENCES users(sabun),
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (project_id, sabun)
);