mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 13:52:40 +02:00
Add system_prompt_slug column and migration for prompt overrides
This commit is contained in:
parent
2024e9b1ed
commit
16f4d007e4
2 changed files with 44 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
"""add system_prompt_slug to prompts
|
||||
|
||||
Revision ID: 113
|
||||
Revises: 112
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "113"
|
||||
down_revision: str | None = "112"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"ALTER TABLE prompts ADD COLUMN IF NOT EXISTS system_prompt_slug VARCHAR(100)"
|
||||
)
|
||||
op.execute(
|
||||
"CREATE INDEX IF NOT EXISTS ix_prompts_system_prompt_slug"
|
||||
" ON prompts (system_prompt_slug)"
|
||||
)
|
||||
op.execute(
|
||||
"ALTER TABLE prompts ADD CONSTRAINT uq_prompt_user_system_slug"
|
||||
" UNIQUE (user_id, system_prompt_slug)"
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute(
|
||||
"ALTER TABLE prompts DROP CONSTRAINT IF EXISTS uq_prompt_user_system_slug"
|
||||
)
|
||||
op.execute("DROP INDEX IF EXISTS ix_prompts_system_prompt_slug")
|
||||
op.execute("ALTER TABLE prompts DROP COLUMN IF EXISTS system_prompt_slug")
|
||||
|
|
@ -1782,6 +1782,13 @@ class PromptMode(StrEnum):
|
|||
|
||||
class Prompt(BaseModel, TimestampMixin):
|
||||
__tablename__ = "prompts"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"user_id",
|
||||
"system_prompt_slug",
|
||||
name="uq_prompt_user_system_slug",
|
||||
),
|
||||
)
|
||||
|
||||
user_id = Column(
|
||||
UUID(as_uuid=True),
|
||||
|
|
@ -1795,6 +1802,7 @@ class Prompt(BaseModel, TimestampMixin):
|
|||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
system_prompt_slug = Column(String(100), nullable=True, index=True)
|
||||
name = Column(String(200), nullable=False)
|
||||
prompt = Column(Text, nullable=False)
|
||||
mode = Column(SQLAlchemyEnum(PromptMode), nullable=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue