"""addition of global noise and download files

Revision ID: 8ba055a43d6d
Revises: 0f3a4026c398
Create Date: 2025-08-25 10:38:22.505832

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '8ba055a43d6d'
down_revision: Union[str, None] = '0f3a4026c398'
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! ###
    op.create_table('global_noises',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('noise', sa.String(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('deleted_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('noise')
    )
    op.create_index(op.f('ix_global_noises_id'), 'global_noises', ['id'], unique=False)
    op.create_table('download_files',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('file_id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('deleted_at', sa.DateTime(), nullable=True),
    sa.Column('file_type', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['file_id'], ['files.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_download_files_id'), 'download_files', ['id'], unique=False)
    op.alter_column('appellations', 'country_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('appellations', 'region_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('sub_appellations', 'country_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('sub_appellations', 'region_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('sub_appellations', 'sub_region_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('sub_appellations', 'sub_region_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('sub_appellations', 'region_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('sub_appellations', 'country_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('appellations', 'region_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('appellations', 'country_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.drop_index(op.f('ix_download_files_id'), table_name='download_files')
    op.drop_table('download_files')
    op.drop_index(op.f('ix_global_noises_id'), table_name='global_noises')
    op.drop_table('global_noises')
    # ### end Alembic commands ###
