🎉 feat(flow_style.py): add FlowStyle model and its CRUD classes

The FlowStyle model is added to the project, which represents the style of a flow. It has a color and an emoji field, and a foreign key to the Flow model. The CRUD classes are also added to the file, which are FlowStyleCreate, FlowStyleRead, and FlowStyleUpdate. These classes are used to create, read, and update FlowStyle instances respectively.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-06 16:24:20 -03:00
commit 32ae6fe0ef

View file

@ -0,0 +1,33 @@
# Path: src/backend/langflow/database/models/flowstyle.py
from langflow.database.models.base import SQLModelSerializable
from sqlmodel import Field, Relationship
from uuid import UUID, uuid4
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from langflow.database.models.flow import Flow
class FlowStyleBase(SQLModelSerializable):
color: str
emoji: str
flow_id: UUID = Field(default=None, foreign_key="flow.id")
class FlowStyle(FlowStyleBase, table=True):
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
flow: "Flow" = Relationship(back_populates="style")
class FlowStyleUpdate(SQLModelSerializable):
color: Optional[str] = None
emoji: Optional[str] = None
class FlowStyleCreate(FlowStyleBase):
pass
class FlowStyleRead(FlowStyleBase):
id: UUID