"""add feature bom context

Revision ID: fc522441a836
Revises: ef8ef6d858a0
Create Date: 2026-08-29 13:34:58.924409

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = 'fc522441a836'
down_revision: Union[str, None] = 'ef8ef6d858a0'
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.add_column('special_feature_bom', sa.Column('model_id', sa.UUID(), nullable=True))
    op.add_column('special_feature_bom', sa.Column('body_type_id', sa.UUID(), nullable=True))
    op.add_column('special_feature_bom', sa.Column('segment_id', sa.UUID(), nullable=True))
    op.drop_constraint('uq_feature_option_rm', 'special_feature_bom', type_='unique')
    op.create_unique_constraint('uq_feature_option_rm_context', 'special_feature_bom', ['option_id', 'model_id', 'body_type_id', 'segment_id', 'rm_id'])
    op.create_foreign_key(None, 'special_feature_bom', 'body_type_master', ['body_type_id'], ['body_type_id'])
    op.create_foreign_key(None, 'special_feature_bom', 'customer_segment_master', ['segment_id'], ['segment_id'])
    op.create_foreign_key(None, 'special_feature_bom', 'vehicle_model_master', ['model_id'], ['model_id'])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'special_feature_bom', type_='foreignkey')
    op.drop_constraint(None, 'special_feature_bom', type_='foreignkey')
    op.drop_constraint(None, 'special_feature_bom', type_='foreignkey')
    op.drop_constraint('uq_feature_option_rm_context', 'special_feature_bom', type_='unique')
    op.create_unique_constraint('uq_feature_option_rm', 'special_feature_bom', ['option_id', 'rm_id'])
    op.drop_column('special_feature_bom', 'segment_id')
    op.drop_column('special_feature_bom', 'body_type_id')
    op.drop_column('special_feature_bom', 'model_id')
    # ### end Alembic commands ###
