- Dockerfile: Poetry 대신 직접 pip 설치로 의존성 문제 해결 - highlights.py: UUID 임포트 추가, 들여쓰기 오류 수정, 1:N 관계 지원 - notes.py: Pydantic v2 호환성 수정, 다중 메모 지원 - models: highlight-note 관계를 1:1에서 1:N으로 변경 - docker-compose.yml: 배포용 환경변수 설정 ✅ 로그인 API 정상 작동 확인 ✅ 나스/맥미니 배포 준비 완료
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""
|
|
메모 모델
|
|
"""
|
|
from sqlalchemy import Column, String, DateTime, Text, Boolean, ForeignKey
|
|
from sqlalchemy.dialects.postgresql import UUID, ARRAY
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
import uuid
|
|
|
|
from ..core.database import Base
|
|
|
|
|
|
class Note(Base):
|
|
"""메모 테이블 (하이라이트와 1:N 관계)"""
|
|
__tablename__ = "notes"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
|
|
# 연결 정보
|
|
highlight_id = Column(UUID(as_uuid=True), ForeignKey("highlights.id"), nullable=False)
|
|
|
|
# 메모 내용
|
|
content = Column(Text, nullable=False)
|
|
is_private = Column(Boolean, default=True) # 개인 메모 여부
|
|
|
|
# 태그 (메모 분류용)
|
|
tags = Column(ARRAY(String), nullable=True) # ["중요", "질문", "아이디어"]
|
|
|
|
# 메타데이터
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# 관계
|
|
highlight = relationship("Highlight", back_populates="notes")
|
|
|
|
@property
|
|
def user_id(self):
|
|
"""하이라이트를 통해 사용자 ID 가져오기"""
|
|
return self.highlight.user_id if self.highlight else None
|
|
|
|
@property
|
|
def document_id(self):
|
|
"""하이라이트를 통해 문서 ID 가져오기"""
|
|
return self.highlight.document_id if self.highlight else None
|
|
|
|
def __repr__(self):
|
|
return f"<Note(id='{self.id}', content='{self.content[:50]}...')>"
|