diff --git a/src/phoenix/db/migrations/versions/bc8fea3c2bc8_add_prompt_tables.py b/src/phoenix/db/migrations/versions/bc8fea3c2bc8_add_prompt_tables.py index 0c8a135986..d3012e70de 100644 --- a/src/phoenix/db/migrations/versions/bc8fea3c2bc8_add_prompt_tables.py +++ b/src/phoenix/db/migrations/versions/bc8fea3c2bc8_add_prompt_tables.py @@ -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( @@ -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), diff --git a/src/phoenix/db/models.py b/src/phoenix/db/models.py index 4c2197458a..52afec0764 100644 --- a/src/phoenix/db/models.py +++ b/src/phoenix/db/models.py @@ -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( @@ -810,8 +810,6 @@ class PromptLabel(Base): uselist=True, ) - __table_args__ = (UniqueConstraint("name"),) - class Prompt(Base): __tablename__ = "prompts" @@ -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( @@ -850,8 +848,6 @@ class Prompt(Base): uselist=True, ) - __table_args__ = (UniqueConstraint("name"),) - class PromptPromptLabel(Base): __tablename__ = "prompts_prompt_labels" @@ -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]