Skip to content

Commit

Permalink
fix: Remove foreign keys and Add relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Nov 13, 2024
1 parent 520adaf commit c1c349c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ def upgrade() -> None:
sa.Column(
"registry_id",
GUID,
sa.ForeignKey("container_registries.id", onupdate="CASCADE", ondelete="CASCADE"),
nullable=False,
),
sa.Column(
"group_id",
GUID,
sa.ForeignKey("groups.id", onupdate="CASCADE", ondelete="CASCADE"),
nullable=False,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Sequence

import sqlalchemy as sa
from sqlalchemy.orm import relationship

from ai.backend.logging import BraceStyleAdapter

Expand All @@ -20,12 +21,22 @@ class AssociationContainerRegistriesGroupsRow(Base):
registry_id = sa.Column(
"registry_id",
GUID,
sa.ForeignKey("container_registries.id", onupdate="CASCADE", ondelete="CASCADE"),
nullable=False,
)
group_id = sa.Column(
"group_id",
GUID,
sa.ForeignKey("groups.id", onupdate="CASCADE", ondelete="CASCADE"),
nullable=False,
)

container_registry_row = relationship(
"ContainerRegistryRow",
back_populates="association_container_registries_groups_rows",
primaryjoin="ContainerRegistryRow.id == foreign(AssociationContainerRegistriesGroupsRow.registry_id)",
)

group_row = relationship(
"GroupRow",
back_populates="association_container_registries_groups_rows",
primaryjoin="GroupRow.id == foreign(AssociationContainerRegistriesGroupsRow.group_id)",
)

0 comments on commit c1c349c

Please sign in to comment.