"""Add is_admin to Contact model

Revision ID: 25da158dd705
Revises: 7a5747dc773f
Create Date: 2025-05-23 16:10:53.731035

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import inspect


# revision identifiers, used by Alembic.
revision = '25da158dd705'
down_revision = '7a5747dc773f'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    inspector = inspect(conn)
    columns = [col['name'] for col in inspector.get_columns('contact')]
    
    with op.batch_alter_table('contact', schema=None) as batch_op:
        if 'is_admin' not in columns:
            batch_op.add_column(sa.Column('is_admin', sa.Boolean(), nullable=True))

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    inspector = inspect(conn)
    columns = [col['name'] for col in inspector.get_columns('contact')]
    
    with op.batch_alter_table('contact', schema=None) as batch_op:
        if 'is_admin' in columns:
            batch_op.drop_column('is_admin')

    # ### end Alembic commands ###
