"""create tcgplayer categories table

Revision ID: 2025_04_09_create_tcgplayer_categories_table
Revises: remove_product_id_unique_constraint
Create Date: 2025-04-09 23:20:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '2025_04_09_create_tcgplayer_categories_table'
down_revision: str = 'remove_product_id_unique_constraint'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table('tcgplayer_categories',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('category_id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.Column('display_name', sa.String(), nullable=True),
        sa.Column('seo_category_name', sa.String(), nullable=True),
        sa.Column('category_description', sa.String(), nullable=True),
        sa.Column('category_page_title', sa.String(), nullable=True),
        sa.Column('sealed_label', sa.String(), nullable=True),
        sa.Column('non_sealed_label', sa.String(), nullable=True),
        sa.Column('condition_guide_url', sa.String(), nullable=True),
        sa.Column('is_scannable', sa.Boolean(), nullable=True, default=False),
        sa.Column('popularity', sa.Integer(), nullable=True, default=0),
        sa.Column('is_direct', sa.Boolean(), nullable=True, default=False),
        sa.Column('modified_on', sa.DateTime(), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('category_id')
    )
    op.create_index('ix_tcgplayer_categories_id', 'tcgplayer_categories', ['id'], unique=False)
    op.create_index('ix_tcgplayer_categories_category_id', 'tcgplayer_categories', ['category_id'], unique=True)


def downgrade() -> None:
    op.drop_index('ix_tcgplayer_categories_category_id', table_name='tcgplayer_categories')
    op.drop_index('ix_tcgplayer_categories_id', table_name='tcgplayer_categories')
    op.drop_table('tcgplayer_categories') 