diff --git a/api/kiwi_vpn_api/db/device.py b/api/kiwi_vpn_api/db/device.py index 2f9e3e1..449b64a 100644 --- a/api/kiwi_vpn_api/db/device.py +++ b/api/kiwi_vpn_api/db/device.py @@ -1,5 +1,5 @@ """ -Python representation of `device` table. +Python representation of `devices` table. """ from __future__ import annotations @@ -44,16 +44,18 @@ class DeviceRead(DeviceBase): class Device(DeviceBase, table=True): """ - Representation of device table + Representation of `devices` table """ + __tablename__ = "devices" + __table_args__ = (UniqueConstraint( "owner_name", "name", ),) id: int | None = Field(primary_key=True) - owner_name: str | None = Field(foreign_key="user.name") + owner_name: str | None = Field(foreign_key="users.name") # no idea, but "User" (in quotes) doesn't work here # might be a future problem? diff --git a/api/kiwi_vpn_api/db/user.py b/api/kiwi_vpn_api/db/user.py index cc5e079..71d3269 100644 --- a/api/kiwi_vpn_api/db/user.py +++ b/api/kiwi_vpn_api/db/user.py @@ -1,5 +1,5 @@ """ -Python representation of `user` table. +Python representation of `users` table. """ from __future__ import annotations @@ -72,9 +72,11 @@ class UserRead(UserBase): class User(UserBase, table=True): """ - Representation of user table + Representation of `users` table """ + __tablename__ = "users" + password: str capabilities: list[UserCapability] = Relationship( diff --git a/api/kiwi_vpn_api/db/user_capability.py b/api/kiwi_vpn_api/db/user_capability.py index 7b98eb7..9fd3cb1 100644 --- a/api/kiwi_vpn_api/db/user_capability.py +++ b/api/kiwi_vpn_api/db/user_capability.py @@ -1,5 +1,5 @@ """ -Python representation of `usercapability` table. +Python representation of `user_capabilities` table. """ from enum import Enum @@ -46,10 +46,12 @@ class UserCapabilityBase(SQLModel): class UserCapability(UserCapabilityBase, table=True): """ - Representation of usercapability table + Representation of `user_capabilities` table """ - user_name: str = Field(primary_key=True, foreign_key="user.name") + __tablename__ = "user_capabilities" + + user_name: str = Field(primary_key=True, foreign_key="users.name") user: "User" = Relationship( back_populates="capabilities",