"""sprint1_customer_master

Revision ID: 7da5dda6fd98
Revises: a39af587038a
Create Date: 2026-07-07 16:33:22.192228

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '7da5dda6fd98'
down_revision: Union[str, None] = 'a39af587038a'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('customer_type_master',
    sa.Column('type_code', sa.String(length=50), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=False),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('type_code')
    )
    op.create_index(op.f('ix_customer_type_master_type_code'), 'customer_type_master', ['type_code'], unique=False)
    op.create_table('transport_master',
    sa.Column('transport_id', sa.String(length=50), nullable=False),
    sa.Column('name', sa.String(length=200), nullable=False),
    sa.Column('contact_person', sa.String(length=100), nullable=True),
    sa.Column('contact_number', sa.String(length=50), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('transport_id')
    )
    op.create_index(op.f('ix_transport_master_transport_id'), 'transport_master', ['transport_id'], unique=False)
    op.create_table('customer_master',
    sa.Column('customer_id', sa.String(length=50), nullable=False),
    sa.Column('name', sa.String(length=200), nullable=False),
    sa.Column('type_code', sa.String(length=50), nullable=True),
    sa.Column('goodwill_reason', sa.Text(), nullable=True),
    sa.Column('gstin', sa.String(length=50), nullable=True),
    sa.Column('pan', sa.String(length=50), nullable=True),
    sa.Column('billing_address', sa.Text(), nullable=True),
    sa.Column('shipping_address', sa.Text(), nullable=True),
    sa.Column('city', sa.String(length=100), nullable=True),
    sa.Column('state', sa.String(length=100), nullable=True),
    sa.Column('pincode', sa.String(length=20), nullable=True),
    sa.Column('region', sa.String(length=50), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['type_code'], ['customer_type_master.type_code'], ),
    sa.PrimaryKeyConstraint('customer_id')
    )
    op.create_index(op.f('ix_customer_master_customer_id'), 'customer_master', ['customer_id'], unique=False)
    op.create_table('customer_contact',
    sa.Column('contact_id', sa.String(length=50), nullable=False),
    sa.Column('customer_id', sa.String(length=50), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=False),
    sa.Column('designation', sa.String(length=100), nullable=True),
    sa.Column('email', sa.String(length=100), nullable=True),
    sa.Column('phone', sa.String(length=50), nullable=True),
    sa.Column('is_primary', sa.Boolean(), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['customer_id'], ['customer_master.customer_id'], ),
    sa.PrimaryKeyConstraint('contact_id')
    )
    op.create_index(op.f('ix_customer_contact_contact_id'), 'customer_contact', ['contact_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_customer_contact_contact_id'), table_name='customer_contact')
    op.drop_table('customer_contact')
    op.drop_index(op.f('ix_customer_master_customer_id'), table_name='customer_master')
    op.drop_table('customer_master')
    op.drop_index(op.f('ix_transport_master_transport_id'), table_name='transport_master')
    op.drop_table('transport_master')
    op.drop_index(op.f('ix_customer_type_master_type_code'), table_name='customer_type_master')
    op.drop_table('customer_type_master')
    # ### end Alembic commands ###
