"""Add type_version default for specialist

Revision ID: 6857672e8164
Revises: 209ae2db55f0
Create Date: 2025-02-10 04:45:46.336174

"""
from alembic import op
import sqlalchemy as sa
import pgvector
from sqlalchemy import table, column, String, text
from sqlalchemy.dialects import postgresql
from sqlalchemy.exc import SQLAlchemyError

# revision identifiers, used by Alembic.
revision = '6857672e8164'
down_revision = '209ae2db55f0'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    connection = op.get_bind()
    table_name = 'specialist'
    try:
        result = connection.execute(
            text(f"""
                        UPDATE {table_name}
                        SET type_version = '1.0.0'
                        WHERE type_version IS NULL OR type_version = ''
                    """)
        )
        print(f"Updated {result.rowcount} rows for type_version in {table_name}")
    except SQLAlchemyError as e:
        print(f"Error updating type_version in {table_name}: {str(e)}")
        raise
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###
