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