"""add-type-column-in-pipeline-table

Revision ID: b8fe483b5a71
Revises: 739c7981bdd8
Create Date: 2024-04-26 16:44:38.800600

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = 'b8fe483b5a71'
down_revision: Union[str, None] = '739c7981bdd8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    # op.drop_table('langchain_pg_collection')
    # op.drop_table('langchain_pg_embedding')
    op.add_column('pipelines', sa.Column('type', sa.Enum('RAG', 'SUMMARIZER', name='pipelinetypemaster'), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('pipelines', 'type')
    op.create_table('langchain_pg_embedding',
    sa.Column('collection_id', sa.UUID(), autoincrement=False, nullable=True),
    sa.Column('embedding', sa.NullType(), autoincrement=False, nullable=True),
    sa.Column('document', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('cmetadata', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('custom_id', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('uuid', sa.UUID(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['collection_id'], ['langchain_pg_collection.uuid'], name='langchain_pg_embedding_collection_id_fkey', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('uuid', name='langchain_pg_embedding_pkey')
    )
    op.create_table('langchain_pg_collection',
    sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('cmetadata', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('uuid', sa.UUID(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('uuid', name='langchain_pg_collection_pkey')
    )
    # ### end Alembic commands ###
