964d4ffc67
library_categories 테이블 추가로 빈 카테고리 생성 가능. CRUD API (생성/leaf rename/leaf delete) + 트리 머지 엔드포인트. 사이드바 트리에 컨텍스트 메뉴 (추가/이름변경/삭제). LibraryPathEditor를 카테고리 기반 flat selector로 전환. 미분류는 시스템 분류로 보호 (삭제/이름변경 불가). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
993 B
Python
26 lines
993 B
Python
"""library_categories 테이블 ORM — 자료실 분류 체계 독립 관리"""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import BigInteger, Boolean, DateTime, Integer, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from core.database import Base
|
|
|
|
|
|
class LibraryCategory(Base):
|
|
__tablename__ = "library_categories"
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
path: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
|
name: Mapped[str] = mapped_column(Text, nullable=False)
|
|
parent_path: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
depth: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
|
is_system: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), default=datetime.now
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), default=datetime.now, onupdate=datetime.now
|
|
)
|