mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
add is_public to prompts model, schema, and migration
This commit is contained in:
parent
3363c71921
commit
f14f09cbe6
3 changed files with 32 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
||||||
|
"""add is_public to prompts
|
||||||
|
|
||||||
|
Revision ID: 112
|
||||||
|
Revises: 111
|
||||||
|
"""
|
||||||
|
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision: str = "112"
|
||||||
|
down_revision: str | None = "111"
|
||||||
|
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 is_public BOOLEAN NOT NULL DEFAULT false"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
op.execute("ALTER TABLE prompts DROP COLUMN IF EXISTS is_public")
|
||||||
|
|
@ -1799,6 +1799,7 @@ class Prompt(BaseModel, TimestampMixin):
|
||||||
prompt = Column(Text, nullable=False)
|
prompt = Column(Text, nullable=False)
|
||||||
mode = Column(SQLAlchemyEnum(PromptMode), nullable=False)
|
mode = Column(SQLAlchemyEnum(PromptMode), nullable=False)
|
||||||
icon = Column(String(50), nullable=True)
|
icon = Column(String(50), nullable=True)
|
||||||
|
is_public = Column(Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
user = relationship("User")
|
user = relationship("User")
|
||||||
search_space = relationship("SearchSpace")
|
search_space = relationship("SearchSpace")
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class PromptCreate(BaseModel):
|
||||||
mode: str = Field(..., pattern="^(transform|explore)$")
|
mode: str = Field(..., pattern="^(transform|explore)$")
|
||||||
icon: str | None = Field(None, max_length=50)
|
icon: str | None = Field(None, max_length=50)
|
||||||
search_space_id: int | None = None
|
search_space_id: int | None = None
|
||||||
|
is_public: bool = False
|
||||||
|
|
||||||
|
|
||||||
class PromptUpdate(BaseModel):
|
class PromptUpdate(BaseModel):
|
||||||
|
|
@ -16,6 +17,7 @@ class PromptUpdate(BaseModel):
|
||||||
prompt: str | None = Field(None, min_length=1)
|
prompt: str | None = Field(None, min_length=1)
|
||||||
mode: str | None = Field(None, pattern="^(transform|explore)$")
|
mode: str | None = Field(None, pattern="^(transform|explore)$")
|
||||||
icon: str | None = Field(None, max_length=50)
|
icon: str | None = Field(None, max_length=50)
|
||||||
|
is_public: bool | None = None
|
||||||
|
|
||||||
|
|
||||||
class PromptRead(BaseModel):
|
class PromptRead(BaseModel):
|
||||||
|
|
@ -25,7 +27,12 @@ class PromptRead(BaseModel):
|
||||||
mode: str
|
mode: str
|
||||||
icon: str | None
|
icon: str | None
|
||||||
search_space_id: int | None
|
search_space_id: int | None
|
||||||
|
is_public: bool
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
|
class PublicPromptRead(PromptRead):
|
||||||
|
author_name: str | None = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue