"""created frames, game, and game player metadata tables

Revision ID: a259288446da
Revises: 
Create Date: 2020-01-28 21:35:07.604169

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

# revision identifiers, used by Alembic.
revision = "a259288446da"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "games",
        sa.Column("game_id", sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint("game_id"),
    )
    op.create_table(
        "game_player_metadata",
        sa.Column("id", sa.Integer(), nullable=True),
        sa.Column("game_id", sa.Integer(), nullable=False),
        sa.Column("match_id", sa.Integer(), nullable=False),
        sa.Column("blue_team", sa.Boolean(), nullable=False),
        sa.Column("esports_player_id", sa.Integer(), nullable=False),
        sa.Column("participant_id", sa.Integer(), nullable=False),
        sa.Column("summoner_name", sa.String(length=50), nullable=False),
        sa.Column("champion_id", sa.String(length=15), nullable=False),
        sa.Column("role", sa.String(length=7), nullable=False),
        sa.ForeignKeyConstraint(["game_id"], ["games.game_id"],),
        sa.PrimaryKeyConstraint("game_id", "participant_id"),
    )
    op.create_table(
        "game_frames",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("game_id", sa.Integer(), nullable=False),
        sa.Column("participant_id", sa.Integer(), nullable=False),
        sa.Column("timestamp", sa.Time(), nullable=False),
        sa.Column("level", sa.Integer(), nullable=False),
        sa.Column("kills", sa.Integer(), nullable=False),
        sa.Column("deaths", sa.Integer(), nullable=False),
        sa.Column("assists", sa.Integer(), nullable=False),
        sa.Column("totalGoldEarned", sa.Integer(), nullable=False),
        sa.Column("creepScore", sa.Integer(), nullable=False),
        sa.Column("killParticipation", sa.Integer(), nullable=False),
        sa.Column("championDamageShare", sa.Integer(), nullable=False),
        sa.Column("wardsPlaced", sa.Integer(), nullable=False),
        sa.Column("wardsDestroyed", sa.Integer(), nullable=False),
        sa.Column("attackDamage", sa.Integer(), nullable=False),
        sa.Column("abilityPower", sa.Integer(), nullable=False),
        sa.Column("criticalChance", sa.Integer(), nullable=False),
        sa.Column("attackSpeed", sa.Integer(), nullable=False),
        sa.Column("lifeSteal", sa.Integer(), nullable=False),
        sa.Column("armor", sa.Integer(), nullable=False),
        sa.Column("magicResistance", sa.Integer(), nullable=False),
        sa.Column("tenacity", sa.Integer(), nullable=False),
        sa.Column("items", postgresql.ARRAY(sa.Integer()), nullable=False),
        sa.Column("main_rune", sa.Integer(), nullable=False),
        sa.Column("second_rune", sa.Integer(), nullable=False),
        sa.Column("rune_choices", postgresql.ARRAY(sa.Integer()), nullable=False),
        sa.Column("abilities", postgresql.ARRAY(sa.VARCHAR(length=1)), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        sa.ForeignKeyConstraint(
            ["game_id", "participant_id"],
            ["game_player_metadata.game_id", "game_player_metadata.participant_id"],
        ),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("game_player_metadata")
    op.drop_table("games")
    op.drop_table("game_frames")
    # ### end Alembic commands ###
