Refactor Variable model in database
This commit is contained in:
parent
dc531de20a
commit
bb3461cf81
1 changed files with 14 additions and 5 deletions
|
|
@ -20,17 +20,26 @@ class VariableBase(SQLModel):
|
||||||
|
|
||||||
|
|
||||||
class Variable(VariableBase, table=True):
|
class Variable(VariableBase, table=True):
|
||||||
id: Optional[UUID] = Field(default_factory=uuid4, primary_key=True, description="Unique ID for the variable")
|
id: Optional[UUID] = Field(
|
||||||
|
default_factory=uuid4,
|
||||||
|
primary_key=True,
|
||||||
|
description="Unique ID for the variable",
|
||||||
|
)
|
||||||
# name is unique per user
|
# name is unique per user
|
||||||
created_at: datetime = Field(default_factory=utc_now, description="Creation time of the variable")
|
created_at: datetime = Field(
|
||||||
updated_at: Optional[datetime] = Field(None, description="Last update time of the variable")
|
default_factory=utc_now, description="Creation time of the variable"
|
||||||
|
)
|
||||||
|
updated_at: Optional[datetime] = Field(
|
||||||
|
None, description="Last update time of the variable"
|
||||||
|
)
|
||||||
# foreign key to user table
|
# foreign key to user table
|
||||||
user_id: UUID = Field(description="User ID associated with this variable", foreign_key="user.id")
|
user_id: UUID = Field(
|
||||||
|
description="User ID associated with this variable", foreign_key="user.id"
|
||||||
|
)
|
||||||
user: "User" = Relationship(back_populates="variables")
|
user: "User" = Relationship(back_populates="variables")
|
||||||
|
|
||||||
|
|
||||||
class VariableCreate(VariableBase):
|
class VariableCreate(VariableBase):
|
||||||
# AcceptedProviders is a custom Enum
|
|
||||||
type: Optional[str] = Field(None, description="Type of the variable")
|
type: Optional[str] = Field(None, description="Type of the variable")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue