File size: 1,728 Bytes
daa4d56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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'),)