"""add_employer_group_to_insurance

Revision ID: b750c7bc32f7
Revises: ce642f83d9a3
Create Date: 2025-07-27 09:53:30.632470

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b750c7bc32f7'
down_revision = 'ce642f83d9a3'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    # Check if column already exists before adding it
    conn = op.get_bind()
    inspector = sa.inspect(conn)
    columns = [col['name'] for col in inspector.get_columns('insurances')]
    
    if 'employer_group' not in columns:
        op.add_column('insurances', sa.Column('employer_group', sa.String(), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    # Check if column exists before dropping it
    conn = op.get_bind()
    inspector = sa.inspect(conn)
    columns = [col['name'] for col in inspector.get_columns('insurances')]
    
    if 'employer_group' in columns:
        op.drop_column('insurances', 'employer_group')
    # ### end Alembic commands ###
