Skip to content

Commit

Permalink
rename tables
Browse files Browse the repository at this point in the history
  • Loading branch information
axiomofjoy committed Dec 20, 2024
1 parent 1cc525c commit 9cdc826
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _(*args: Any, **kwargs: Any) -> str:

def upgrade() -> None:
op.create_table(
"prompt_tag_configs",
"prompt_labels",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("name", sa.String, nullable=False, unique=True),
sa.Column("description", sa.String),
Expand Down Expand Up @@ -80,12 +80,12 @@ def upgrade() -> None:
)

op.create_table(
"prompt_tags",
"prompts_prompt_labels",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column(
"prompt_tag_config_id",
"prompt_label_id",
sa.Integer,
sa.ForeignKey("prompt_tag_configs.id", ondelete="CASCADE"),
sa.ForeignKey("prompt_labels.id", ondelete="CASCADE"),
nullable=False,
index=True,
),
Expand Down Expand Up @@ -149,7 +149,7 @@ def upgrade() -> None:
)

op.create_table(
"prompt_template_version_tags",
"prompt_tags",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("name", sa.String, nullable=False),
sa.Column("description", sa.String, nullable=True),
Expand Down Expand Up @@ -182,8 +182,8 @@ def upgrade() -> None:


def downgrade() -> None:
op.drop_table("prompt_template_version_tags")
op.drop_table("prompt_versions")
op.drop_table("prompt_tags")
op.drop_table("prompt_versions")
op.drop_table("prompts_prompt_labels")
op.drop_table("prompts")
op.drop_table("prompt_tag_configs")
op.drop_table("prompt_labels")
44 changes: 22 additions & 22 deletions src/phoenix/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,16 @@ class ApiKey(Base):
__table_args__ = (dict(sqlite_autoincrement=True),)


class PromptTagConfig(Base):
__tablename__ = "prompt_tag_configs"
class PromptLabel(Base):
__tablename__ = "prompt_labels"

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

prompt_tags: Mapped[list["PromptTag"]] = relationship(
"PromptTag",
back_populates="prompt_tag_config",
prompts_prompt_labels: Mapped[list["PromptPromptLabel"]] = relationship(
"PromptPromptLabel",
back_populates="prompt_labels",
cascade="all, delete-orphan",
uselist=True,
)
Expand All @@ -829,8 +829,8 @@ class Prompt(Base):
UtcTimeStamp, server_default=func.now(), onupdate=func.now()
)

prompt_tags: Mapped[list["PromptTag"]] = relationship(
"PromptTag",
prompts_prompt_labels: Mapped[list["PromptPromptLabel"]] = relationship(
"PromptPromptLabel",
back_populates="prompt",
cascade="all, delete-orphan",
uselist=True,
Expand All @@ -843,8 +843,8 @@ class Prompt(Base):
uselist=True,
)

prompt_template_version_tags: Mapped[list["PromptTemplateVersionTag"]] = relationship(
"PromptTemplateVersionTag",
prompt_tags: Mapped[list["PromptTag"]] = relationship(
"PromptTag",
back_populates="prompt",
cascade="all, delete-orphan",
uselist=True,
Expand All @@ -853,12 +853,12 @@ class Prompt(Base):
__table_args__ = (UniqueConstraint("name"),)


class PromptTag(Base):
__tablename__ = "prompt_tags"
class PromptPromptLabel(Base):
__tablename__ = "prompts_prompt_labels"

id: Mapped[int] = mapped_column(primary_key=True)
prompt_tag_config_id: Mapped[int] = mapped_column(
ForeignKey("prompt_tag_configs.id", ondelete="CASCADE"),
prompt_label_id: Mapped[int] = mapped_column(
ForeignKey("prompt_labels.id", ondelete="CASCADE"),
index=True,
nullable=False,
)
Expand All @@ -868,10 +868,10 @@ class PromptTag(Base):
nullable=False,
)

prompt_tag_config: Mapped["PromptTagConfig"] = relationship(
"PromptTagConfig", back_populates="prompt_tags"
prompt_label: Mapped["PromptLabel"] = relationship(
"PromptLabel", back_populates="prompts_prompt_labels"
)
prompt: Mapped["Prompt"] = relationship("Prompt", back_populates="prompt_tags")
prompt: Mapped["Prompt"] = relationship("Prompt", back_populates="prompts_prompt_labels")


class PromptVersion(Base):
Expand Down Expand Up @@ -915,16 +915,16 @@ class PromptVersion(Base):

prompt: Mapped["Prompt"] = relationship("Prompt", back_populates="prompt_versions")

prompt_template_version_tags: Mapped[list["PromptTemplateVersionTag"]] = relationship(
"PromptTemplateVersionTag",
prompt_tags: Mapped[list["PromptTag"]] = relationship(
"PromptTag",
back_populates="prompt_version",
cascade="all, delete-orphan",
uselist=True,
)


class PromptTemplateVersionTag(Base):
__tablename__ = "prompt_template_version_tags"
class PromptTag(Base):
__tablename__ = "prompt_tags"

id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String, nullable=False)
Expand All @@ -945,9 +945,9 @@ class PromptTemplateVersionTag(Base):
nullable=True,
)

prompt: Mapped["Prompt"] = relationship("Prompt", back_populates="prompt_template_version_tags")
prompt: Mapped["Prompt"] = relationship("Prompt", back_populates="prompt_tags")
prompt_version: Mapped["PromptVersion"] = relationship(
"PromptVersion", back_populates="prompt_template_version_tags"
"PromptVersion", back_populates="prompt_tags"
)

__table_args__ = (UniqueConstraint("name", "prompt_id"),)

0 comments on commit 9cdc826

Please sign in to comment.