"""pokken_fix_pokemon_uk

Revision ID: 3657efefc5a4
Revises: 4a02e623e5e6
Create Date: 2024-06-13 23:50:57.611998

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '3657efefc5a4'
down_revision = '4a02e623e5e6'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('pokken_pokemon_data', 'char_id',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=True)
    op.alter_column('pokken_pokemon_data', 'illustration_book_no',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=False)
    op.drop_constraint('pokken_pokemon_data_ibfk_1', table_name='pokken_pokemon_data', type_='foreignkey')
    op.drop_index('pokken_pokemon_data_uk', table_name='pokken_pokemon_data')
    op.create_unique_constraint('pokken_pokemon_uk', 'pokken_pokemon_data', ['user', 'illustration_book_no'])
    op.create_foreign_key("pokken_pokemon_data_ibfk_1", "pokken_pokemon_data", "aime_user", ['user'], ['id'])
    op.alter_column('pokken_profile', 'trainer_name',
               existing_type=mysql.VARCHAR(length=16),
               type_=sa.String(length=14),
               existing_nullable=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('pokken_profile', 'trainer_name',
               existing_type=sa.String(length=14),
               type_=mysql.VARCHAR(length=16),
               existing_nullable=True)
    op.drop_constraint('pokken_pokemon_data_ibfk_1', table_name='pokken_pokemon_data', type_='foreignkey')
    op.drop_constraint('pokken_pokemon_uk', 'pokken_pokemon_data', type_='unique')
    op.create_index('pokken_pokemon_data_uk', 'pokken_pokemon_data', ['user', 'char_id'], unique=True)
    op.create_foreign_key("pokken_pokemon_data_ibfk_1", "pokken_pokemon_data", "aime_user", ['user'], ['id'])
    op.alter_column('pokken_pokemon_data', 'illustration_book_no',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=True)
    op.alter_column('pokken_pokemon_data', 'char_id',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=False)
    # ### end Alembic commands ###
