fix linkup enum migration file

This commit is contained in:
CREDO23 2025-08-13 21:18:33 +02:00
parent d70ebf9669
commit 24dff5f875

View file

@ -2,7 +2,7 @@
Revision ID: 4
Revises: 3
Create Date: 2025-08-13
"""
from collections.abc import Sequence
@ -17,31 +17,29 @@ depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# Manually add the command to add the enum value
op.execute("ALTER TYPE searchsourceconnectortype ADD VALUE 'LINKUP_API'")
# Pass for the rest, as autogenerate didn't run to add other schema details
pass
# ### end Alembic commands ###
# Add enum value only if it doesn't already exist.
# Postgres will no-op with a NOTICE when the value is present.
op.execute(
"ALTER TYPE searchsourceconnectortype ADD VALUE IF NOT EXISTS 'LINKUP_API'"
)
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# Downgrading removal of an enum value requires recreating the type
# To "remove" an enum value in Postgres, we must recreate the type
# without that value, migrate the column, then drop the old type.
op.execute(
"ALTER TYPE searchsourceconnectortype RENAME TO searchsourceconnectortype_old"
)
op.execute(
"CREATE TYPE searchsourceconnectortype AS ENUM('SERPER_API', 'TAVILY_API', 'SLACK_CONNECTOR', 'NOTION_CONNECTOR', 'GITHUB_CONNECTOR', 'LINEAR_CONNECTOR')"
"CREATE TYPE searchsourceconnectortype AS ENUM("
"'SERPER_API', 'TAVILY_API', 'SLACK_CONNECTOR', "
"'NOTION_CONNECTOR', 'GITHUB_CONNECTOR', 'LINEAR_CONNECTOR'"
")"
)
op.execute(
"ALTER TABLE search_source_connectors ALTER COLUMN connector_type TYPE searchsourceconnectortype USING "
"connector_type::text::searchsourceconnectortype"
"ALTER TABLE search_source_connectors "
"ALTER COLUMN connector_type "
"TYPE searchsourceconnectortype "
"USING connector_type::text::searchsourceconnectortype"
)
op.execute("DROP TYPE searchsourceconnectortype_old")
pass
# ### end Alembic commands ###