"""v0.5.0

Revision ID: 07d58b1c19f2
Revises: 23ac8207d1d2
Create Date: 2026-04-02 13:27:49.104119

"""
from typing import Sequence, Union

import sqlmodel
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '07d58b1c19f2'
down_revision: Union[str, None] = '23ac8207d1d2'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('book', schema=None) as batch_op:
        batch_op.add_column(sa.Column('file_url', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
        batch_op.add_column(sa.Column('cover_url', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
        batch_op.drop_column('file_name')
        batch_op.drop_column('cover_name')

    with op.batch_alter_table('file_meta', schema=None) as batch_op:
        batch_op.add_column(sa.Column('sha1', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=True))
        batch_op.drop_column('path')

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('file_meta', schema=None) as batch_op:
        batch_op.add_column(sa.Column('path', sa.VARCHAR(), autoincrement=False, nullable=True))
        batch_op.drop_column('sha1')

    with op.batch_alter_table('book', schema=None) as batch_op:
        batch_op.add_column(sa.Column('cover_name', sa.VARCHAR(), autoincrement=False, nullable=True))
        batch_op.add_column(sa.Column('file_name', sa.VARCHAR(), autoincrement=False, nullable=True))
        batch_op.drop_column('cover_url')
        batch_op.drop_column('file_url')

    # ### end Alembic commands ###
