"""Add user_tags table for tag management

Revision ID: 15ccd7e6129d
Revises: 22e7b6e7ed69
Create Date: 2025-09-21 09:29:08.321284

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '15ccd7e6129d'
down_revision = '22e7b6e7ed69'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_tags',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('tag', sa.String(length=100), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'tag', name='uq_user_tag')
    )
    op.create_index('idx_user_tags_tag', 'user_tags', ['tag'], unique=False)
    op.create_index('idx_user_tags_user_id', 'user_tags', ['user_id'], unique=False)
    op.create_index(op.f('ix_user_tags_id'), 'user_tags', ['id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_user_tags_id'), table_name='user_tags')
    op.drop_index('idx_user_tags_user_id', table_name='user_tags')
    op.drop_index('idx_user_tags_tag', table_name='user_tags')
    op.drop_table('user_tags')
    # ### end Alembic commands ###
