Skip to content

Commit

Permalink
add explicit index
Browse files Browse the repository at this point in the history
  • Loading branch information
axiomofjoy committed Dec 20, 2024
1 parent 9cdc826 commit 4f7f8e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def upgrade() -> None:
op.create_table(
"prompt_labels",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("name", sa.String, nullable=False, unique=True),
sa.Column("description", sa.String),
sa.Column("name", sa.String, nullable=False, unique=True, index=True),
sa.Column("description", sa.String, nullable=True),
)

op.create_table(
Expand All @@ -62,8 +62,8 @@ def upgrade() -> None:
nullable=True,
index=True,
),
sa.Column("name", sa.String, unique=True, nullable=False),
sa.Column("description", sa.String),
sa.Column("name", sa.String, unique=True, index=True, nullable=False),
sa.Column("description", sa.String, nullable=True),
sa.Column(
"created_at",
sa.TIMESTAMP(timezone=True),
Expand Down
14 changes: 5 additions & 9 deletions src/phoenix/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ class PromptLabel(Base):
__tablename__ = "prompt_labels"

id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String, unique=True, nullable=False)
name: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
description: Mapped[Optional[str]]

prompts_prompt_labels: Mapped[list["PromptPromptLabel"]] = relationship(
Expand All @@ -810,8 +810,6 @@ class PromptLabel(Base):
uselist=True,
)

__table_args__ = (UniqueConstraint("name"),)


class Prompt(Base):
__tablename__ = "prompts"
Expand All @@ -822,7 +820,7 @@ class Prompt(Base):
index=True,
nullable=True,
)
name: Mapped[str] = mapped_column(String, unique=True, nullable=False)
name: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
description: Mapped[Optional[str]]
created_at: Mapped[datetime] = mapped_column(UtcTimeStamp, server_default=func.now())
updated_at: Mapped[datetime] = mapped_column(
Expand Down Expand Up @@ -850,8 +848,6 @@ class Prompt(Base):
uselist=True,
)

__table_args__ = (UniqueConstraint("name"),)


class PromptPromptLabel(Base):
__tablename__ = "prompts_prompt_labels"
Expand Down Expand Up @@ -903,11 +899,11 @@ class PromptVersion(Base):
)
template: Mapped[dict[str, Any]] = mapped_column(JsonDict, nullable=False)
invocation_parameters: Mapped[Optional[dict[str, Any]]] = mapped_column(
JsonDict, default=dict, nullable=True
JsonDict, default=None, nullable=True
)
tools: Mapped[Optional[dict[str, Any]]] = mapped_column(JsonDict, default=dict, nullable=True)
tools: Mapped[Optional[dict[str, Any]]] = mapped_column(JsonDict, default=None, nullable=True)
output_schema: Mapped[Optional[dict[str, Any]]] = mapped_column(
JsonDict, default=dict, nullable=True
JsonDict, default=None, nullable=True
)
model_provider: Mapped[str]
model_name: Mapped[str]
Expand Down

0 comments on commit 4f7f8e1

Please sign in to comment.