mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
feat(automation): wire SQLAlchemy relationships on both sides
This commit is contained in:
parent
7ac99b89a0
commit
7f4c1c25ab
4 changed files with 60 additions and 0 deletions
|
|
@ -1533,6 +1533,14 @@ class SearchSpace(BaseModel, TimestampMixin):
|
|||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
automations = relationship(
|
||||
"Automation",
|
||||
back_populates="search_space",
|
||||
order_by="Automation.id",
|
||||
cascade="all, delete-orphan",
|
||||
passive_deletes=True,
|
||||
)
|
||||
|
||||
# RBAC relationships
|
||||
roles = relationship(
|
||||
"SearchSpaceRole",
|
||||
|
|
@ -2125,6 +2133,13 @@ if config.AUTH_TYPE == "GOOGLE":
|
|||
passive_deletes=True,
|
||||
)
|
||||
|
||||
# Automations created by this user
|
||||
automations = relationship(
|
||||
"Automation",
|
||||
back_populates="created_by",
|
||||
passive_deletes=True,
|
||||
)
|
||||
|
||||
# Incentive tasks completed by this user
|
||||
incentive_tasks = relationship(
|
||||
"UserIncentiveTask",
|
||||
|
|
@ -2257,6 +2272,13 @@ else:
|
|||
passive_deletes=True,
|
||||
)
|
||||
|
||||
# Automations created by this user
|
||||
automations = relationship(
|
||||
"Automation",
|
||||
back_populates="created_by",
|
||||
passive_deletes=True,
|
||||
)
|
||||
|
||||
# Incentive tasks completed by this user
|
||||
incentive_tasks = relationship(
|
||||
"UserIncentiveTask",
|
||||
|
|
@ -2560,6 +2582,16 @@ class RefreshToken(Base, TimestampMixin):
|
|||
return not self.is_expired and not self.is_revoked
|
||||
|
||||
|
||||
# Register model packages that live outside this file so their classes
|
||||
# are present in Base.metadata before configure_mappers() resolves any
|
||||
# string-based relationship() references.
|
||||
from app.automations.persistence import ( # noqa: E402, F401
|
||||
Automation,
|
||||
AutomationRun,
|
||||
AutomationTrigger,
|
||||
)
|
||||
|
||||
|
||||
engine = create_async_engine(
|
||||
DATABASE_URL,
|
||||
pool_size=30,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue