From 54dcbfa288a5ff7c98b460892d7695f199f4ac52 Mon Sep 17 00:00:00 2001 From: hagen-danswer Date: Thu, 12 Dec 2024 17:41:11 -0800 Subject: [PATCH] made description optional for document sets (#3407) * made description optional for document sets * update document set optional * update alembic migration head --------- Co-authored-by: pablodanswer --- ..._make_document_set_description_optional.py | 30 +++++++++++++++++++ backend/danswer/db/models.py | 2 +- .../server/features/document_set/models.py | 2 +- .../sets/DocumentSetCreationForm.tsx | 5 ++-- 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 backend/alembic/versions/94dc3d0236f8_make_document_set_description_optional.py diff --git a/backend/alembic/versions/94dc3d0236f8_make_document_set_description_optional.py b/backend/alembic/versions/94dc3d0236f8_make_document_set_description_optional.py new file mode 100644 index 00000000000..202e12b3a1f --- /dev/null +++ b/backend/alembic/versions/94dc3d0236f8_make_document_set_description_optional.py @@ -0,0 +1,30 @@ +"""make document set description optional + +Revision ID: 94dc3d0236f8 +Revises: bf7a81109301 +Create Date: 2024-12-11 11:26:10.616722 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "94dc3d0236f8" +down_revision = "bf7a81109301" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Make document_set.description column nullable + op.alter_column( + "document_set", "description", existing_type=sa.String(), nullable=True + ) + + +def downgrade() -> None: + # Revert document_set.description column to non-nullable + op.alter_column( + "document_set", "description", existing_type=sa.String(), nullable=False + ) diff --git a/backend/danswer/db/models.py b/backend/danswer/db/models.py index 2fd40dfce4e..7cd8af803fc 100644 --- a/backend/danswer/db/models.py +++ b/backend/danswer/db/models.py @@ -1226,7 +1226,7 @@ class DocumentSet(Base): id: Mapped[int] = mapped_column(Integer, primary_key=True) name: Mapped[str] = mapped_column(String, unique=True) - description: Mapped[str] = mapped_column(String) + description: Mapped[str | None] = mapped_column(String) user_id: Mapped[UUID | None] = mapped_column( ForeignKey("user.id", ondelete="CASCADE"), nullable=True ) diff --git a/backend/danswer/server/features/document_set/models.py b/backend/danswer/server/features/document_set/models.py index 740cb6906cf..696bf5c9177 100644 --- a/backend/danswer/server/features/document_set/models.py +++ b/backend/danswer/server/features/document_set/models.py @@ -44,7 +44,7 @@ class CheckDocSetPublicResponse(BaseModel): class DocumentSet(BaseModel): id: int name: str - description: str + description: str | None cc_pair_descriptors: list[ConnectorCredentialPairDescriptor] is_up_to_date: bool is_public: bool diff --git a/web/src/app/admin/documents/sets/DocumentSetCreationForm.tsx b/web/src/app/admin/documents/sets/DocumentSetCreationForm.tsx index 1691b9c46d8..3f7f4b1b85d 100644 --- a/web/src/app/admin/documents/sets/DocumentSetCreationForm.tsx +++ b/web/src/app/admin/documents/sets/DocumentSetCreationForm.tsx @@ -65,9 +65,7 @@ export const DocumentSetCreationForm = ({ }} validationSchema={Yup.object().shape({ name: Yup.string().required("Please enter a name for the set"), - description: Yup.string().required( - "Please enter a description for the set" - ), + description: Yup.string().optional(), cc_pair_ids: Yup.array() .of(Yup.number().required()) .required("Please select at least one connector"), @@ -125,6 +123,7 @@ export const DocumentSetCreationForm = ({ label="Description:" placeholder="Describe what the document set represents" autoCompleteDisabled={true} + optional={true} /> {isPaidEnterpriseFeaturesEnabled && (