"""Add company information fields to SiteSettings

Revision ID: 787468cfea77
Revises: 9faab7ef6036
Create Date: 2025-05-26 10:42:17.287566

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


# revision identifiers, used by Alembic.
revision = '787468cfea77'
down_revision = '9faab7ef6036'
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('site_settings')]
    
    with op.batch_alter_table('site_settings', schema=None) as batch_op:
        if 'company_website' not in columns:
            batch_op.add_column(sa.Column('company_website', sa.String(length=200), nullable=True))
        if 'company_email' not in columns:
            batch_op.add_column(sa.Column('company_email', sa.String(length=100), nullable=True))
        if 'company_phone' not in columns:
            batch_op.add_column(sa.Column('company_phone', sa.String(length=20), nullable=True))
        if 'company_address' not in columns:
            batch_op.add_column(sa.Column('company_address', sa.String(length=200), nullable=True))
        if 'company_city' not in columns:
            batch_op.add_column(sa.Column('company_city', sa.String(length=100), nullable=True))
        if 'company_state' not in columns:
            batch_op.add_column(sa.Column('company_state', sa.String(length=100), nullable=True))
        if 'company_zip' not in columns:
            batch_op.add_column(sa.Column('company_zip', sa.String(length=20), nullable=True))
        if 'company_country' not in columns:
            batch_op.add_column(sa.Column('company_country', sa.String(length=100), nullable=True))
        if 'company_description' not in columns:
            batch_op.add_column(sa.Column('company_description', sa.Text(), nullable=True))
        if 'company_industry' not in columns:
            batch_op.add_column(sa.Column('company_industry', sa.String(length=100), nullable=True))

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('site_settings', schema=None) as batch_op:
        batch_op.drop_column('company_industry')
        batch_op.drop_column('company_description')
        batch_op.drop_column('company_country')
        batch_op.drop_column('company_zip')
        batch_op.drop_column('company_state')
        batch_op.drop_column('company_city')
        batch_op.drop_column('company_address')
        batch_op.drop_column('company_phone')
        batch_op.drop_column('company_email')
        batch_op.drop_column('company_website')

    # ### end Alembic commands ###
