From b2abda9b7c878dacc106b2aff5f89d04f2011f55 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Wed, 13 Nov 2024 08:35:40 +0000 Subject: [PATCH] fix: Add association table relationship --- src/ai/backend/manager/models/container_registry.py | 8 +++++++- src/ai/backend/manager/models/group.py | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ai/backend/manager/models/container_registry.py b/src/ai/backend/manager/models/container_registry.py index 292f3a455b..29988e63c1 100644 --- a/src/ai/backend/manager/models/container_registry.py +++ b/src/ai/backend/manager/models/container_registry.py @@ -12,7 +12,7 @@ import yarl from graphql import Undefined, UndefinedType from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.orm import load_only +from sqlalchemy.orm import load_only, relationship from sqlalchemy.orm.exc import NoResultFound from ai.backend.common.exception import UnknownImageRegistry @@ -82,6 +82,12 @@ class ContainerRegistryRow(Base): ) extra = sa.Column("extra", sa.JSON, nullable=True, default=None) + association_container_registries_groups_rows = relationship( + "AssociationContainerRegistriesGroupsRow", + back_populates="container_registry_row", + primaryjoin="ContainerRegistryRow.id == foreign(AssociationContainerRegistriesGroupsRow.registry_id)", + ) + @classmethod async def get( cls, diff --git a/src/ai/backend/manager/models/group.py b/src/ai/backend/manager/models/group.py index 1a12e63873..7337a77907 100644 --- a/src/ai/backend/manager/models/group.py +++ b/src/ai/backend/manager/models/group.py @@ -210,6 +210,11 @@ class GroupRow(Base): back_populates="group_row", primaryjoin="GroupRow.id == foreign(VFolderRow.group)", ) + association_container_registries_groups_rows = relationship( + "AssociationContainerRegistriesGroupsRow", + back_populates="group_row", + primaryjoin="GroupRow.id == foreign(AssociationContainerRegistriesGroupsRow.group_id)", + ) @dataclass