"""Setup initial crack schema

Revision ID: 406c96d25e5e
Revises: 
Create Date: 2020-07-31 15:23:28.430194+00:00

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('artist',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('year_founded', sa.Date(), nullable=True),
    sa.Column('country', sa.String(length=32), nullable=True),
    sa.Column('about', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('genre',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('highlights', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('release',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('label', sa.String(length=64), nullable=True),
    sa.Column('type', sa.String(length=32), nullable=True),
    sa.Column('album_kind', sa.String(length=32), nullable=True),
    sa.Column('release_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('song',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('trivia', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('artist_release',
    sa.Column('artist_id', sa.Integer(), nullable=False),
    sa.Column('release_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['artist_id'], ['artist.id'], ),
    sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
    sa.PrimaryKeyConstraint('artist_id', 'release_id')
    )
    op.create_table('genre_artist',
    sa.Column('genre_id', sa.Integer(), nullable=False),
    sa.Column('artist_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['artist_id'], ['artist.id'], ),
    sa.ForeignKeyConstraint(['genre_id'], ['genre.id'], ),
    sa.PrimaryKeyConstraint('genre_id', 'artist_id')
    )
    op.create_table('genre_release',
    sa.Column('genre_id', sa.Integer(), nullable=False),
    sa.Column('release_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['genre_id'], ['genre.id'], ),
    sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
    sa.PrimaryKeyConstraint('genre_id', 'release_id')
    )
    op.create_table('release_song',
    sa.Column('release_id', sa.Integer(), nullable=False),
    sa.Column('song_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
    sa.ForeignKeyConstraint(['song_id'], ['song.id'], ),
    sa.PrimaryKeyConstraint('release_id', 'song_id')
    )
    op.create_table('sheet',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date_uploaded', sa.Date(), nullable=True),
    sa.Column('bpm', sa.Integer(), nullable=True),
    sa.Column('song_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['song_id'], ['song.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tracktab',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('instrument', sa.String(length=32), nullable=True),
    sa.Column('time_start', sa.Time(), nullable=True),
    sa.Column('tuning', sa.String(length=64), nullable=True),
    sa.Column('gp5', sa.LargeBinary(), nullable=True),
    sa.Column('sheet_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['sheet_id'], ['sheet.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tracktab')
    op.drop_table('sheet')
    op.drop_table('release_song')
    op.drop_table('genre_release')
    op.drop_table('genre_artist')
    op.drop_table('artist_release')
    op.drop_table('song')
    op.drop_table('release')
    op.drop_table('genre')
    op.drop_table('artist')
    # ### end Alembic commands ###
