123
This commit is contained in:
24
backend/shared/models/task.py
Normal file
24
backend/shared/models/task.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""Task ORM model."""
|
||||
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, String
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from .base import Base
|
||||
|
||||
|
||||
class Task(Base):
|
||||
__tablename__ = "tasks"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
account_id = Column(String(36), ForeignKey("accounts.id", ondelete="CASCADE"), nullable=False)
|
||||
cron_expression = Column(String(50), nullable=False)
|
||||
is_enabled = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
|
||||
account = relationship("Account", back_populates="tasks")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Task(id={self.id}, cron='{self.cron_expression}')>"
|
||||
Reference in New Issue
Block a user