"""base structure

Revision ID: ad617e352b38
Revises: 
Create Date: 2019-06-11 13:06:58.054085

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'ad617e352b38'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('channels',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=10), nullable=False),
                    sa.Column('url', sa.String(length=200), nullable=False),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('songs',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('title', sa.String(length=200), nullable=False),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_index(op.f('ix_songs_title'), 'songs', ['title'], unique=False, postgresql_using='hash')
    op.create_table('history',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
                    sa.Column('song_id', sa.Integer(), nullable=False),
                    sa.Column('channel_id', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ondelete='RESTRICT'),
                    sa.ForeignKeyConstraint(['song_id'], ['songs.id'], ondelete='RESTRICT'),
                    sa.PrimaryKeyConstraint('id')
                    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('history')
    op.drop_index(op.f('ix_songs_title'), table_name='songs')
    op.drop_table('songs')
    op.drop_table('channels')
    # ### end Alembic commands ###
