From 442417b8082390689aa2f0598e24cb8e588a5eb7 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 30 Jul 2025 21:35:27 +0200 Subject: [PATCH] add migration file --- .../15_add_clickup_connector_enums.py | 63 +++++++++++++++++++ surfsense_backend/app/db.py | 2 + 2 files changed, 65 insertions(+) create mode 100644 surfsense_backend/alembic/versions/15_add_clickup_connector_enums.py diff --git a/surfsense_backend/alembic/versions/15_add_clickup_connector_enums.py b/surfsense_backend/alembic/versions/15_add_clickup_connector_enums.py new file mode 100644 index 0000000..4f339c0 --- /dev/null +++ b/surfsense_backend/alembic/versions/15_add_clickup_connector_enums.py @@ -0,0 +1,63 @@ +"""Add ClickUp connector enums + +Revision ID: 15_add_clickup_connector_enums +Revises: 14_add_confluence_connector_enums +Create Date: 2025-07-29 12:00:00.000000 + +""" + +from typing import Sequence, Union + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "15_add_clickup_connector_enums" +down_revision: Union[str, None] = "14_add_confluence_connector_enums" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Safely add 'CLICKUP_CONNECTOR' to enum types if missing.""" + + # Add to searchsourceconnectortype enum + op.execute( + """ + DO $$ + BEGIN + IF NOT EXISTS ( + SELECT 1 FROM pg_type t + JOIN pg_enum e ON t.oid = e.enumtypid + WHERE t.typname = 'searchsourceconnectortype' AND e.enumlabel = 'CLICKUP_CONNECTOR' + ) THEN + ALTER TYPE searchsourceconnectortype ADD VALUE 'CLICKUP_CONNECTOR'; + END IF; + END + $$; + """ + ) + + # Add to documenttype enum + op.execute( + """ + DO $$ + BEGIN + IF NOT EXISTS ( + SELECT 1 FROM pg_type t + JOIN pg_enum e ON t.oid = e.enumtypid + WHERE t.typname = 'documenttype' AND e.enumlabel = 'CLICKUP_CONNECTOR' + ) THEN + ALTER TYPE documenttype ADD VALUE 'CLICKUP_CONNECTOR'; + END IF; + END + $$; + """ + ) + + +def downgrade() -> None: + """Remove 'CLICKUP_CONNECTOR' from enum types.""" + # Note: PostgreSQL doesn't support removing enum values directly + # This would require recreating the enum type, which is complex + # For now, we'll leave the enum values in place + pass diff --git a/surfsense_backend/app/db.py b/surfsense_backend/app/db.py index b067752..1b7da7e 100644 --- a/surfsense_backend/app/db.py +++ b/surfsense_backend/app/db.py @@ -44,6 +44,7 @@ class DocumentType(str, Enum): DISCORD_CONNECTOR = "DISCORD_CONNECTOR" JIRA_CONNECTOR = "JIRA_CONNECTOR" CONFLUENCE_CONNECTOR = "CONFLUENCE_CONNECTOR" + CLICKUP_CONNECTOR = "CLICKUP_CONNECTOR" class SearchSourceConnectorType(str, Enum): @@ -57,6 +58,7 @@ class SearchSourceConnectorType(str, Enum): DISCORD_CONNECTOR = "DISCORD_CONNECTOR" JIRA_CONNECTOR = "JIRA_CONNECTOR" CONFLUENCE_CONNECTOR = "CONFLUENCE_CONNECTOR" + CLICKUP_CONNECTOR = "CLICKUP_CONNECTOR" class ChatType(str, Enum):