"""alter table customer_contacts

Revision ID: 6d5f196d1d4e
Revises: 7735307a6a3a
Create Date: 2025-11-25 15:03:48.031415

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '6d5f196d1d4e'
down_revision: Union[str, Sequence[str], None] = '7735307a6a3a'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('customer_contacts', sa.Column('first_name', sa.String(length=255), nullable=True))
    op.add_column('customer_contacts', sa.Column('last_name', sa.String(length=255), nullable=True))
    op.add_column('customer_contacts', sa.Column('title', sa.String(length=255), nullable=True))
    op.add_column('customer_contacts', sa.Column('account_phone', sa.String(length=255), nullable=True))
    op.add_column('customer_contacts', sa.Column('account_website', sa.String(length=255), nullable=True))
    op.alter_column('customer_contacts', 'designation',
               existing_type=sa.VARCHAR(length=255),
               nullable=True)
    # Make user_account_id nullable in customer_contacts table
    op.alter_column('customer_contacts', 'user_account_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.drop_column('customer_contacts', 'name')
    op.drop_column('customer_contacts', 'website')
    op.alter_column('customers', 'account_type',
               existing_type=sa.VARCHAR(length=255),
               nullable=True)
    op.alter_column('customers', 'industry',
               existing_type=sa.VARCHAR(length=255),
               nullable=True)
    op.alter_column('customers', 'user_account_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('customers', 'user_account_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('customers', 'industry',
               existing_type=sa.VARCHAR(length=255),
               nullable=False)
    op.alter_column('customers', 'account_type',
               existing_type=sa.VARCHAR(length=255),
               nullable=False)
    op.add_column('customer_contacts', sa.Column('website', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('customer_contacts', sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False))
    op.alter_column('customer_contacts', 'designation',
               existing_type=sa.VARCHAR(length=255),
               nullable=False)
    # Revert user_account_id to not nullable in customer_contacts table
    op.alter_column('customer_contacts', 'user_account_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.drop_column('customer_contacts', 'account_website')
    op.drop_column('customer_contacts', 'account_phone')
    op.drop_column('customer_contacts', 'title')
    op.drop_column('customer_contacts', 'last_name')
    op.drop_column('customer_contacts', 'first_name')
    # ### end Alembic commands ###