table names
This commit is contained in:
parent
270de7f87c
commit
5b623e885c
3 changed files with 14 additions and 8 deletions
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue