from sqlalchemy import String, Integer, JSON, Text, UniqueConstraint from sqlalchemy.orm import Mapped, mapped_column from KnowledgeService.models import Base class Resource(Base): __tablename__='platform_resource' tenant:Mapped[str]=mapped_column(String(80),primary_key=True) owner:Mapped[str]=mapped_column(String(80),primary_key=True) kind:Mapped[str]=mapped_column(String(32),primary_key=True) id:Mapped[str]=mapped_column(String(80),primary_key=True) revision:Mapped[int]=mapped_column(Integer) body:Mapped[dict]=mapped_column(JSON) updated_at:Mapped[str]=mapped_column(String(40)) class Schedule(Base): __tablename__='platform_schedule' id:Mapped[str]=mapped_column(String(80),primary_key=True) tenant:Mapped[str]=mapped_column(String(80),index=True) owner:Mapped[str]=mapped_column(String(80),index=True) revision:Mapped[int]=mapped_column(Integer) body:Mapped[dict]=mapped_column(JSON) status:Mapped[str]=mapped_column(String(24)) next_at:Mapped[str|None]=mapped_column(String(40),index=True) updated_at:Mapped[str]=mapped_column(String(40)) class ScheduledRun(Base): __tablename__='platform_scheduled_run' id:Mapped[str]=mapped_column(String(80),primary_key=True) schedule_id:Mapped[str]=mapped_column(String(80),index=True) tenant:Mapped[str]=mapped_column(String(80)) owner:Mapped[str]=mapped_column(String(80)) slot:Mapped[str]=mapped_column(String(80)) status:Mapped[str]=mapped_column(String(24)) result:Mapped[dict]=mapped_column(JSON) created_at:Mapped[str]=mapped_column(String(40)) __table_args__=(UniqueConstraint('schedule_id','slot',name='uq_schedule_slot'),)