chore: Supabase 스키마 구축 및 DB 타입 시스템 셋업 (#30) - #32
Conversation
📝 WalkthroughWalkthroughSupabase 스키마, RLS, 시드 데이터를 마이그레이션으로 동기화했고, 생성된 DB 타입과 제네릭 헬퍼를 추가했다. workspace 도메인 DB 타입 export를 정리했으며, 타입 생성 스크립트, ignore 설정, 컨벤션 문서도 함께 반영했다. ChangesSupabase 스키마 및 타입 생성
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/shared/model/database.types.ts`:
- Around line 704-710: `database.types.ts`의 `Functions` 타입이 실제 RPC 목록과 불일치합니다.
`is_workspace_member`/`is_workspace_owner`만 두지 말고, `create_workspace`와
`get_my_workspaces`를 `Functions`에 추가해 `src/shared/model/database.types.ts`를 최신
스키마에 맞추세요. `create_workspace`와 `get_my_workspaces`를 참조하는 `workspace` API 주석과 타입
생성 결과가 서로 일치하는지 함께 확인해 정리하세요.
In `@supabase/migrations/20260709025327_create_enums_and_core_tables.sql`:
- Line 45: `setup_status` is currently defined as free-form text, unlike the
other status/domain fields, so it can store invalid values. Update the
enum/table definition in the migration that creates the core tables to constrain
`setup_status` the same way as `task_status` and `resource_type`—prefer a
dedicated ENUM or, if that is not feasible, add a CHECK constraint. Also make
sure the corresponding constraints in `add_constraints.sql` are updated so the
`setup_status` values are validated consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8c34b5ba-8ce1-4d2a-85d7-c36d433d48d1
📒 Files selected for processing (11)
.prettierignoredocs/conventions/supabase-convention.mdpackage.jsonsrc/entities/workspace/index.tssrc/entities/workspace/model/workspace.db.types.tssrc/shared/model/database.types.tssrc/shared/model/supabase.types.tssupabase/migrations/20260709025327_create_enums_and_core_tables.sqlsupabase/migrations/20260709025457_seed_test_users_and_data.sqlsupabase/migrations/20260709025820_add_auth_rls_policies.sqlsupabase/migrations/20260709032015_add_constraints.sql
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@supabase/migrations/20260709034833_move_rls_helpers_to_private_schema.sql`:
- Around line 12-18: The migration in the private-schema RLS helper setup should
explicitly remove schema access for anon/public in addition to function execute
grants. Update the `private.is_workspace_member` and
`private.is_workspace_owner` permission block to also revoke `USAGE` on the
`private` schema from `anon` and `public`, keeping the existing `grant
usage`/`grant execute` for `authenticated` intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 95b3ed7d-ceb6-4d30-9446-34251c9b3647
📒 Files selected for processing (2)
src/shared/model/database.types.tssupabase/migrations/20260709034833_move_rls_helpers_to_private_schema.sql
Pull Request
작업 내용
database.types.ts(자동 생성) +supabase.types.ts(Generic 헬퍼) +npm run gen:typesworkspace.db.types.ts) — 다른 도메인이 따라갈 기준 구현docs/conventions/supabase-convention.md)작업 결과
syncly프로젝트(teamplerun org)에 적용 완료된 스키마가 레포와 일치:workspace_purpose/task_status/task_priority/task_category/resource_type/calendar_event_type/member_rolesprints) + updated_at 자동 갱신 트리거 + FK 인덱스auth.uid()기반 실 정책 전 테이블 작성 완료 (Security Definer 헬퍼is_workspace_member/is_workspace_owner). 현재는dev_full_access임시 정책이 공존해 전체 허용 — auth 연동 시 dev 정책만 drop하면 발동profiles(email)unique, CHECK 3건test1@test.com~test5@test.com/test1234!— 실제 로그인 가능한 auth 계정...1001캡스톤 디자인 팀(team_project) ·...1002Fitto 앱 개발팀(side_project) ·...1003카페 그레이 운영(store_operation), 5명 전원 멤버get_my_workspaces형태 집계, 벨로시티(스프린트별 포인트 합계) 집계 쿼리 동작 검증 완료변경 사항
Added
supabase/migrations/— 4건, 원격schema_migrations버전과 파일명 일치create_enums_and_core_tables/seed_test_users_and_data/add_auth_rls_policies/add_constraintssrc/shared/model/database.types.ts— 자동 생성 DB 타입 (직접 수정·직접 import 금지)src/shared/model/supabase.types.ts— Generic 헬퍼 6종 (GenericTables/Insert/Update/GenericEnums/GenericFunctionArgs/GenericFunctionReturns)src/entities/workspace/model/workspace.db.types.ts— workspace 도메인 DB 타입 (기준 구현)docs/conventions/supabase-convention.md— 타입 사용 규칙 · 쓰기 경로(RPC vs 직접 쿼리) · ENUM · 마이그레이션 · 테스트 시드 정리package.json—gen:types스크립트 (npx supabase gen types typescript ...)Changed
entities/workspacePublic API에 DB 타입 export 추가.prettierignore— 자동 생성 파일(database.types.ts)·supabase/migrations제외Fixed
실행화면
테스트
lint/typecheck/ 신규 파일format:check통과)리뷰 체크리스트
feature/*->develop, 배포 시develop또는release/*->main)Type/#issue-number/description형식을 따릅니다.console.log, 주석, 임시 코드를 제거했습니다.리뷰 요청사항
p_user_id uuid파라미터로 유저를 받습니다 (auth.uid()는 세션이 없어 null). 테스트는 시드 계정 id(00000000-...-0001등) 사용 → auth 연동 후 일괄 교체 예정입니다.docs/conventions/supabase-convention.md)work_schedule_entries는 ERD안(날짜식work_date)대로 생성했습니다. 요일 반복식으로 확정되면 ALTER 1회로 전환 예정 (스케줄 담당자분 확인 부탁드려요)entities/<도메인>/model/<도메인>.db.types.ts패턴으로 만들어 쓰시면 됩니다 (workspace 참고)관련 이슈
Closes #30
Summary by CodeRabbit