From 93fcef1878706457b562aad06a93869bba0adcd7 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Tue, 26 Aug 2025 00:09:53 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20user=5Fid=20UUID=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=20=EB=B6=88=EC=9D=BC=EC=B9=98=20=EB=AC=B8=EC=A0=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PostgreSQL conversation_logs 테이블 스키마 문제 - slack_user_id 컬럼 추가 솔루션 - rb8001 코드 수정 방안 제시 --- ...6_happybell80_rb8001_이중저장구현.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/troubleshooting/250826_happybell80_rb8001_이중저장구현.md b/troubleshooting/250826_happybell80_rb8001_이중저장구현.md index 70052a6..1461d5e 100644 --- a/troubleshooting/250826_happybell80_rb8001_이중저장구현.md +++ b/troubleshooting/250826_happybell80_rb8001_이중저장구현.md @@ -151,6 +151,65 @@ graph LR --- +## 추가 문제 해결 (user_id UUID 타입 불일치) + +### 발견된 문제 +1. **PostgreSQL 저장 실패** + ``` + PostgreSQL save failed: invalid input syntax for type uuid: "system" + PostgreSQL save failed: invalid input syntax for type uuid: "U0925SXQFDK" + ``` + +2. **원인 분석** + - conversation_logs 테이블의 user_id가 UUID 타입 + - rb8001은 Slack user ID (문자열) 전송 + - UUID 변환 불가능한 값으로 저장 실패 + +### DB 스키마 수정 (51123 서버) +```sql +-- slack_user_id 컬럼 추가 +ALTER TABLE conversation_logs +ADD COLUMN slack_user_id VARCHAR(255); + +-- user_id를 nullable로 변경 +ALTER TABLE conversation_logs +ALTER COLUMN user_id DROP NOT NULL; +``` + +### rb8001 코드 수정 필요 +```python +# router.py:338 수정 +conversation_log = ConversationLog( + robeing_id=settings.ROBEING_ID, + slack_user_id=user_id, # user_id 대신 slack_user_id 사용 + channel_id=channel, + message=message, + response=response, + intent=intent, + confidence=confidence +) +``` + +### database.py 모델 수정 +```python +class ConversationLog(Base): + """대화 로그 테이블""" + __tablename__ = "conversation_logs" + + id = Column(Integer, primary_key=True, index=True) + robeing_id = Column(String, index=True) + user_id = Column(String, nullable=True) # UUID 타입, nullable + slack_user_id = Column(String) # Slack ID 저장용 + channel_id = Column(String) + message = Column(String) + response = Column(String) + intent = Column(String) + confidence = Column(Float) + timestamp = Column(DateTime, default=datetime.utcnow) +``` + +--- + ## 모니터링 ### 로그 확인