"""empty message

Revision ID: 283e42870163
Revises: 
Create Date: 2020-03-15 15:19:54.736435

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('events',
    sa.Column('id', sa.String(length=100), autoincrement=False, nullable=False),
    sa.Column('title', sa.String(length=100), nullable=True),
    sa.Column('source', sa.String(length=500), nullable=True),
    sa.Column('url', sa.String(length=500), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('id')
    )
    op.create_index(op.f('ix_events_source'), 'events', ['source'], unique=False)
    op.create_index(op.f('ix_events_title'), 'events', ['title'], unique=False)
    op.create_index(op.f('ix_events_url'), 'events', ['url'], unique=False)
    op.create_table('teams',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_teams_name'), 'teams', ['name'], unique=False)
    op.create_table('tournament',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_tournament_name'), 'tournament', ['name'], unique=False)
    op.create_table('event_state',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('event_id', sa.String(length=100), nullable=True),
    sa.Column('tournament_id', sa.Integer(), nullable=True),
    sa.Column('tournament_rel_id', sa.Integer(), nullable=True),
    sa.Column('bestof', sa.Integer(), nullable=True),
    sa.Column('state', sa.Integer(), nullable=True),
    sa.Column('date_start_text', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['event_id'], ['events.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['tournament_rel_id'], ['tournament.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('scores',
    sa.Column('id', sa.String(length=100), autoincrement=False, nullable=False),
    sa.Column('event_state_id', sa.Integer(), nullable=True),
    sa.Column('team_id', sa.Integer(), nullable=True),
    sa.Column('team_rel_id', sa.Integer(), nullable=True),
    sa.Column('score', sa.Integer(), nullable=True),
    sa.Column('winner', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['event_state_id'], ['event_state.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['team_rel_id'], ['teams.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('scores')
    op.drop_table('event_state')
    op.drop_index(op.f('ix_tournament_name'), table_name='tournament')
    op.drop_table('tournament')
    op.drop_index(op.f('ix_teams_name'), table_name='teams')
    op.drop_table('teams')
    op.drop_index(op.f('ix_events_url'), table_name='events')
    op.drop_index(op.f('ix_events_title'), table_name='events')
    op.drop_index(op.f('ix_events_source'), table_name='events')
    op.drop_table('events')
    # ### end Alembic commands ###
