feat: implement task dependencies with validation and update handling
This commit is contained in:
31
backend/app/models/task_dependencies.py
Normal file
31
backend/app/models/task_dependencies.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from sqlalchemy import CheckConstraint, UniqueConstraint
|
||||
from sqlmodel import Field
|
||||
|
||||
from app.core.time import utcnow
|
||||
from app.models.tenancy import TenantScoped
|
||||
|
||||
|
||||
class TaskDependency(TenantScoped, table=True):
|
||||
__tablename__ = "task_dependencies"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"task_id",
|
||||
"depends_on_task_id",
|
||||
name="uq_task_dependencies_task_id_depends_on_task_id",
|
||||
),
|
||||
CheckConstraint(
|
||||
"task_id <> depends_on_task_id",
|
||||
name="ck_task_dependencies_no_self",
|
||||
),
|
||||
)
|
||||
|
||||
id: UUID = Field(default_factory=uuid4, primary_key=True)
|
||||
board_id: UUID = Field(foreign_key="boards.id", index=True)
|
||||
task_id: UUID = Field(foreign_key="tasks.id", index=True)
|
||||
depends_on_task_id: UUID = Field(foreign_key="tasks.id", index=True)
|
||||
created_at: datetime = Field(default_factory=utcnow)
|
||||
Reference in New Issue
Block a user