"""Add columns to track table

Revision ID: 1bc727e5e87f
Revises: 52d82712d218
Create Date: 2021-03-22 22:43:40.458197

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

# revision identifiers, used by Alembic.
revision = '1bc727e5e87f'
down_revision = '52d82712d218'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('tracks', sa.Column('duration', sa.Integer(), nullable=True))
    op.add_column('tracks', sa.Column('fade_at', sa.Integer(), nullable=True))
    op.add_column('tracks', sa.Column('silence_at', sa.Integer(), nullable=True))
    op.add_column('tracks', sa.Column('start_gap', sa.Integer(), nullable=True))
    op.drop_index('ix_tracks_length', table_name='tracks')
    op.create_index(op.f('ix_tracks_duration'), 'tracks', ['duration'], unique=False)
    op.drop_column('tracks', 'length')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('tracks', sa.Column('length', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_tracks_duration'), table_name='tracks')
    op.create_index('ix_tracks_length', 'tracks', ['length'], unique=False)
    op.drop_column('tracks', 'start_gap')
    op.drop_column('tracks', 'silence_at')
    op.drop_column('tracks', 'fade_at')
    op.drop_column('tracks', 'duration')
    # ### end Alembic commands ###
