feat: client endpoints fixes for client tab in deal editor
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship, backref
|
||||
|
||||
from models.base import BaseModel
|
||||
from models.mixins import SoftDeleteMixin, CreatedAtMixin, IdMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from models import Status, Board, DealStatusHistory
|
||||
from modules.clients.models import Client
|
||||
|
||||
|
||||
class Deal(BaseModel, IdMixin, SoftDeleteMixin, CreatedAtMixin):
|
||||
@ -33,3 +34,11 @@ class Deal(BaseModel, IdMixin, SoftDeleteMixin, CreatedAtMixin):
|
||||
cascade="all, delete-orphan",
|
||||
lazy="noload",
|
||||
)
|
||||
|
||||
# module client
|
||||
client_id: Mapped[Optional[int]] = mapped_column(
|
||||
ForeignKey("clients.id", ondelete="CASCADE"),
|
||||
)
|
||||
client: Mapped["Client"] = relationship(
|
||||
backref=backref("deals", cascade="all, delete-orphan"), lazy="immediate"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user