table names

This commit is contained in:
Jörn-Michael Miehe 2022-03-28 21:26:47 +00:00
parent 270de7f87c
commit 5b623e885c
3 changed files with 14 additions and 8 deletions

View file

@ -1,5 +1,5 @@
""" """
Python representation of `device` table. Python representation of `devices` table.
""" """
from __future__ import annotations from __future__ import annotations
@ -44,16 +44,18 @@ class DeviceRead(DeviceBase):
class Device(DeviceBase, table=True): class Device(DeviceBase, table=True):
""" """
Representation of device table Representation of `devices` table
""" """
__tablename__ = "devices"
__table_args__ = (UniqueConstraint( __table_args__ = (UniqueConstraint(
"owner_name", "owner_name",
"name", "name",
),) ),)
id: int | None = Field(primary_key=True) 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 # no idea, but "User" (in quotes) doesn't work here
# might be a future problem? # might be a future problem?

View file

@ -1,5 +1,5 @@
""" """
Python representation of `user` table. Python representation of `users` table.
""" """
from __future__ import annotations from __future__ import annotations
@ -72,9 +72,11 @@ class UserRead(UserBase):
class User(UserBase, table=True): class User(UserBase, table=True):
""" """
Representation of user table Representation of `users` table
""" """
__tablename__ = "users"
password: str password: str
capabilities: list[UserCapability] = Relationship( capabilities: list[UserCapability] = Relationship(

View file

@ -1,5 +1,5 @@
""" """
Python representation of `usercapability` table. Python representation of `user_capabilities` table.
""" """
from enum import Enum from enum import Enum
@ -46,10 +46,12 @@ class UserCapabilityBase(SQLModel):
class UserCapability(UserCapabilityBase, table=True): 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( user: "User" = Relationship(
back_populates="capabilities", back_populates="capabilities",