Skip to content

Commit

Permalink
Fix owner relationship in nat schema
Browse files Browse the repository at this point in the history
Refs #330
  • Loading branch information
lukasjuhrich committed Sep 6, 2023
1 parent c2e1427 commit 85720bb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pycroft/model/nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class OutsideIPAddress(ModelBase):
nat_domain = relationship(NATDomain)

ip_address = Column(IPAddress, primary_key=True, nullable=False)
owner = Column(Integer, ForeignKey(User))
owner_id = Column(Integer, ForeignKey(User.id))
owner = relationship(User, backref="outside_ip_addresses")

__table_args__ = (
single_ipv4_constraint(col=ip_address),
Expand All @@ -66,11 +67,9 @@ class Translation(ModelBase):

outside_address = Column(IPAddress, primary_key=True, nullable=False)
inside_network = Column(IPNetwork, nullable=False)

owner_id = Column(Integer, ForeignKey(User.id, ondelete="CASCADE"),
nullable=False)
owner = relationship(User, backref=backref("translations",
cascade="all, delete-orphan"))
owner = relationship(User,
secondary=OutsideIPAddress.__table__,
backref="translations")

__table_args__ = (
single_ipv4_constraint(col=outside_address),
Expand Down

0 comments on commit 85720bb

Please sign in to comment.