"""remote placeholders: track availability, album/artist remote ids

Revision ID: dc126696f5a6
Revises: 20260614_dl_track_id
Create Date: 2026-06-14 11:25:30.643588
"""

from __future__ import annotations

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = 'dc126696f5a6'
down_revision: str | None = '20260614_dl_track_id'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('albums', sa.Column('source', sa.String(length=32), nullable=True))
    op.add_column('albums', sa.Column('source_id', sa.String(length=512), nullable=True))
    op.create_unique_constraint('uq_albums_source_source_id', 'albums', ['source', 'source_id'])
    op.add_column('artists', sa.Column('source', sa.String(length=32), nullable=True))
    op.add_column('artists', sa.Column('source_id', sa.String(length=512), nullable=True))
    op.create_unique_constraint('uq_artists_source_source_id', 'artists', ['source', 'source_id'])
    op.add_column(
        'tracks',
        sa.Column('availability', sa.String(length=16), nullable=False, server_default='local'),
    )
    op.alter_column('tracks', 'availability', server_default=None)
    op.alter_column('tracks', 'storage_uri',
               existing_type=sa.VARCHAR(length=2048),
               nullable=True)
    op.alter_column('tracks', 'file_format',
               existing_type=sa.VARCHAR(length=32),
               nullable=True)
    op.alter_column('tracks', 'file_size',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('tracks', 'file_size',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('tracks', 'file_format',
               existing_type=sa.VARCHAR(length=32),
               nullable=False)
    op.alter_column('tracks', 'storage_uri',
               existing_type=sa.VARCHAR(length=2048),
               nullable=False)
    op.drop_column('tracks', 'availability')
    op.drop_constraint('uq_artists_source_source_id', 'artists', type_='unique')
    op.drop_column('artists', 'source_id')
    op.drop_column('artists', 'source')
    op.drop_constraint('uq_albums_source_source_id', 'albums', type_='unique')
    op.drop_column('albums', 'source_id')
    op.drop_column('albums', 'source')
    # ### end Alembic commands ###
