"""add_global_tag_tree_numbers

Revision ID: 2b16c6562fff
Revises: c1d91928e145
Create Date: 2026-07-14 05:55:29.594607
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa


revision: str = '2b16c6562fff'
down_revision: Union[str, None] = 'c1d91928e145'
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('global_tag_tree_numbers',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('tag_id', sa.Uuid(), nullable=False),
    sa.Column('tree_number', sa.String(length=100), nullable=False),
    sa.Column('tree_category', sa.String(length=10), nullable=False),
    sa.Column('is_primary', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['tag_id'], ['global_tags.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('tag_id', 'tree_number', name='uq_gttn_tag_tree')
    )
    op.create_index('ix_gttn_tag_id', 'global_tag_tree_numbers', ['tag_id'], unique=False)
    op.create_index('ix_gttn_tree_category', 'global_tag_tree_numbers', ['tree_category'], unique=False)
    op.create_index('ix_gttn_tree_number', 'global_tag_tree_numbers', ['tree_number'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_gttn_tree_number', table_name='global_tag_tree_numbers')
    op.drop_index('ix_gttn_tree_category', table_name='global_tag_tree_numbers')
    op.drop_index('ix_gttn_tag_id', table_name='global_tag_tree_numbers')
    op.drop_table('global_tag_tree_numbers')
    # ### end Alembic commands ###
