"""Add address fields to companies and contacts tables.

Revision ID: 0006_add_addresses
Revises: 0005_user_role_fk
Create Date: 2026-07-04
"""

from __future__ import annotations

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

revision: str = "0006_add_addresses"
down_revision: Union[str, None] = "0005_user_role_fk"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Add address columns to companies
    op.add_column("companies", sa.Column("address_street", sa.String(255), nullable=True))
    op.add_column("companies", sa.Column("address_city", sa.String(100), nullable=True))
    op.add_column("companies", sa.Column("address_zip", sa.String(20), nullable=True))
    op.add_column("companies", sa.Column("address_country", sa.String(2), nullable=True))
    op.add_column("companies", sa.Column("address_state", sa.String(100), nullable=True))

    # Add address columns to contacts
    op.add_column("contacts", sa.Column("address_street", sa.String(255), nullable=True))
    op.add_column("contacts", sa.Column("address_city", sa.String(100), nullable=True))
    op.add_column("contacts", sa.Column("address_zip", sa.String(20), nullable=True))
    op.add_column("contacts", sa.Column("address_country", sa.String(2), nullable=True))
    op.add_column("contacts", sa.Column("address_state", sa.String(100), nullable=True))


def downgrade() -> None:
    op.drop_column("contacts", "address_state")
    op.drop_column("contacts", "address_country")
    op.drop_column("contacts", "address_zip")
    op.drop_column("contacts", "address_city")
    op.drop_column("contacts", "address_street")
    op.drop_column("companies", "address_state")
    op.drop_column("companies", "address_country")
    op.drop_column("companies", "address_zip")
    op.drop_column("companies", "address_city")
    op.drop_column("companies", "address_street")
