Refactor Variable model in database

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-25 17:35:50 -03:00
commit bb3461cf81

View file

@ -20,17 +20,26 @@ class VariableBase(SQLModel):
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
created_at: datetime = Field(default_factory=utc_now, description="Creation time of the variable")
updated_at: Optional[datetime] = Field(None, description="Last update time of the variable")
created_at: datetime = Field(
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
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")
class VariableCreate(VariableBase):
# AcceptedProviders is a custom Enum
type: Optional[str] = Field(None, description="Type of the variable")