fix: PostgreSQL 테이블 변경 계획 문서 오류 수정
- 작성일 형식 수정 (2025-09-10 → 250910) - users 테이블: picture vs avatar_url 모델 차이 명시 - slack_user_mapping: slack_workspace_id 컬럼 추가 - slack_workspaces: company_id → workspace_id 마이그레이션 충돌 명시 - conversation_logs: rb8001과 robeing-monitor 모델 차이 명시 - 개별 로빙 DB 추측 내용 제거 - 위험 요소에 모델 불일치 항목 추가
This commit is contained in:
parent
c45626d0db
commit
ce1a2a92e4
@ -1,7 +1,7 @@
|
||||
# PostgreSQL 데이터베이스 테이블 변경 계획
|
||||
|
||||
## 작성 정보
|
||||
- **작성일**: 2025-09-10
|
||||
- **작성일**: 250910
|
||||
- **작성자**: happybell80
|
||||
- **목적**: PostgreSQL 테이블 구조 대대적 변경에 따른 영향 범위 파악 및 수정 계획
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
### 메인 데이터베이스
|
||||
- **main_db**: `postgresql://robeings:robeings@192.168.219.45:5432/main_db`
|
||||
- **robeing_metrics**: `postgresql://postgres:@172.17.0.1:5432/robeing_metrics`
|
||||
- **개별 로빙 DB**: `postgresql://postgres:postgres@localhost/{ROBEING_ID}_db`
|
||||
|
||||
### 사용 라이브러리
|
||||
| 저장소 | 라이브러리 |
|
||||
@ -26,17 +25,19 @@
|
||||
## 2. 테이블별 사용 위치 상세
|
||||
|
||||
### 2.1 users 테이블
|
||||
**컬럼**: id(UUID), username, email, name, avatar_url, oauth_provider, oauth_id, is_active, created_at, updated_at, last_login_at
|
||||
**컬럼**:
|
||||
- auth-server 모델: id(UUID), username, email, name, **picture**, oauth_provider, oauth_id, is_active, created_at, updated_at, last_login_at
|
||||
- robeing-gateway 모델: id(UUID), username, email, name, **avatar_url**, oauth_provider, oauth_id, is_active, created_at, updated_at, last_login_at
|
||||
|
||||
| 파일 경로 | 라인 번호 | 작업 내용 |
|
||||
|-----------|-----------|-----------|
|
||||
| auth-server/app/models/user.py | 21-35 | 테이블 모델 정의 |
|
||||
| auth-server/app/models/user.py | 21-35 | 테이블 모델 정의 (picture 컬럼) |
|
||||
| auth-server/app/providers/gmail_passport.py | 178 | SELECT id FROM users WHERE username = $1 |
|
||||
| auth-server/app/providers/gmail_passport.py | 187 | SELECT username FROM users WHERE id = $1 |
|
||||
| robeing-gateway/app/database.py | 98-112 | JOIN 쿼리 (workspace_members, workspaces와 함께) |
|
||||
| robeing-gateway/app/database.py | 182-191 | SELECT * FROM users WHERE username = $1 |
|
||||
| robeing-gateway/app/database.py | 321-328 | SELECT * FROM users (전체 조회) |
|
||||
| robeing-gateway/app/models.py | 11-24 | 테이블 모델 정의 |
|
||||
| robeing-gateway/app/models.py | 11-24 | 테이블 모델 정의 (avatar_url 컬럼) |
|
||||
|
||||
### 2.2 workspaces 테이블
|
||||
**컬럼**: id(UUID), name, subdomain, robeing_id, robeing_port, robeing_url, max_members, workspace_type, status, created_at, updated_at
|
||||
@ -64,22 +65,24 @@
|
||||
| robeing-gateway/app/models.py | 46-60 | 테이블 모델 정의 |
|
||||
|
||||
### 2.4 slack_user_mapping 테이블
|
||||
**컬럼**: slack_user_id, user_id
|
||||
**컬럼**: slack_user_id, slack_workspace_id, user_id
|
||||
**주의**: (slack_user_id, slack_workspace_id) 조합이 고유 키
|
||||
|
||||
| 파일 경로 | 라인 번호 | 작업 내용 |
|
||||
|-----------|-----------|-----------|
|
||||
| auth-server/app/providers/slack.py | 266 | SELECT user_id FROM slack_user_mapping WHERE slack_user_id = :slack_user_id |
|
||||
| auth-server/app/providers/slack.py | 308-312 | INSERT INTO slack_user_mapping ... DO UPDATE SET |
|
||||
| auth-server/app/providers/slack.py | 266 | SELECT user_id FROM slack_user_mapping WHERE slack_user_id = :slack_user_id AND slack_workspace_id = :slack_workspace_id |
|
||||
| auth-server/app/providers/slack.py | 308-312 | INSERT INTO slack_user_mapping ... DO UPDATE SET (slack_user_id, slack_workspace_id 조합 기준) |
|
||||
| rb8001/app/router/router.py | 92 | SELECT user_id FROM slack_user_mapping WHERE slack_user_id = :slack_id |
|
||||
| robeing-gateway/app/main.py | 479-486 | SELECT user_id FROM slack_user_mapping WHERE slack_user_id = $1 |
|
||||
|
||||
### 2.5 slack_workspaces 테이블
|
||||
**컬럼**: id(UUID), company_id(UUID), team_id, team_name, bot_token, bot_user_id, app_id, scopes(JSON), is_enterprise_install, is_active, installed_at, updated_at
|
||||
**컬럼**: id(UUID), workspace_id(UUID), team_id, team_name, bot_token, bot_user_id, app_id, scopes(JSON), is_enterprise_install, is_active, installed_at, updated_at
|
||||
**주의**: 마이그레이션에서 company_id → workspace_id로 컬럼명 변경 정의됨
|
||||
|
||||
| 파일 경로 | 라인 번호 | 작업 내용 |
|
||||
|-----------|-----------|-----------|
|
||||
| auth-server/app/models/workspace.py | 43-62 | 테이블 모델 정의 |
|
||||
| auth-server/migrations/add_user_workspace_tables.sql | 60-76 | ALTER TABLE 정의 |
|
||||
| auth-server/app/models/workspace.py | 43-62 | 테이블 모델 정의 (현재 company_id로 정의됨) |
|
||||
| auth-server/migrations/add_user_workspace_tables.sql | 60-76 | ALTER TABLE 정의 (company_id → workspace_id 변경) |
|
||||
| robeing-gateway/app/main.py | 522-525 | SELECT bot_token FROM slack_workspaces WHERE team_id = $1 |
|
||||
| robeing-gateway/app/main.py | 567-570 | SELECT bot_token FROM slack_workspaces WHERE team_id = $1 |
|
||||
|
||||
@ -136,17 +139,19 @@
|
||||
| robeing-monitor/app/state/state_service.py | 133 | SELECT 쿼리 |
|
||||
|
||||
### 2.10 conversation_logs 테이블
|
||||
**컬럼**: id, robeing_id, user_id, slack_user_id, channel_id, message, response, intent, confidence, timestamp
|
||||
**컬럼**:
|
||||
- rb8001 모델: id, robeing_id, user_id, **slack_user_id**, channel_id, message, response, intent, confidence, timestamp
|
||||
- robeing-monitor 모델: id, robeing_id, user_id, channel_id, message, response, intent, confidence, timestamp (slack_user_id 없음)
|
||||
|
||||
| 파일 경로 | 라인 번호 | 작업 내용 |
|
||||
|-----------|-----------|-----------|
|
||||
| rb8001/app/state/database.py | 52-65 | 테이블 모델 정의 |
|
||||
| rb8001/app/state/database.py | 86-92 | SELECT 쿼리 (최근 대화) |
|
||||
| rb8001/app/router/router.py | 464-496 | INSERT 쿼리 |
|
||||
| robeing-monitor/app/state/database.py | 47-59 | 테이블 모델 정의 |
|
||||
| robeing-monitor/app/state/state_service.py | 156-159 | INSERT 쿼리 |
|
||||
| robeing-monitor/app/state/state_service.py | 173-177 | SELECT 쿼리 (최근 로그) |
|
||||
| robeing-monitor/app/state/state_service.py | 194-203 | SELECT 쿼리 (7일간) |
|
||||
| rb8001/app/state/database.py | 52-65 | 테이블 모델 정의 (slack_user_id 포함) |
|
||||
| rb8001/app/state/database.py | 86-92 | SELECT 쿼리 (최근 대화, slack_user_id 포함) |
|
||||
| rb8001/app/router/router.py | 464-496 | INSERT 쿼리 (slack_user_id 포함) |
|
||||
| robeing-monitor/app/state/database.py | 47-59 | 테이블 모델 정의 (slack_user_id 없음) |
|
||||
| robeing-monitor/app/state/state_service.py | 156-159 | INSERT 쿼리 (slack_user_id 없음) |
|
||||
| robeing-monitor/app/state/state_service.py | 173-177 | SELECT 쿼리 (최근 로그, slack_user_id 없음) |
|
||||
| robeing-monitor/app/state/state_service.py | 194-203 | SELECT 쿼리 (7일간, slack_user_id 없음) |
|
||||
|
||||
### 2.11 user_preferences 테이블
|
||||
**컬럼**: user_id, slack_user_id, news_keywords, email_filter, briefing_enabled, briefing_time
|
||||
@ -204,6 +209,8 @@
|
||||
3. **JSON 컬럼**: preferences, scopes, oauth_config 등 JSON 타입 컬럼 처리 주의
|
||||
4. **외래키 관계**: workspace_members의 workspace_id, user_id FK 관계 유지
|
||||
5. **gen_random_uuid()**: PostgreSQL 함수 사용 부분 확인 필요
|
||||
6. **모델 불일치**: 같은 테이블에 대한 서로 다른 모델 정의 (users의 picture vs avatar_url, conversation_logs의 slack_user_id 유무)
|
||||
7. **마이그레이션 충돌**: slack_workspaces의 company_id → workspace_id 변경이 모델과 불일치
|
||||
|
||||
## 5. 작업 우선순위
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user