"""Add primary key to score and history table for DDR Ace ghost ID.

Revision ID: 7e87f51ab94d
Revises: 428e24dea6f3
Create Date: 2018-01-19 23:19:07.408309

"""
from alembic import op
from sqlalchemy.sql import text


# revision identifiers, used by Alembic.
revision = '7e87f51ab94d'
down_revision = '428e24dea6f3'
branch_labels = None
depends_on = None


def upgrade():
    # Alembic doesn't seem to be able to add auto-increment columns properly, so
    # lets do it ourselves.
    conn = op.get_bind()
    sql = 'alter table score add column `id` int auto_increment primary key first'
    results = conn.execute(text(sql), {})
    sql = 'alter table score_history add column `id` int auto_increment primary key first'
    results = conn.execute(text(sql), {})


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('score_history', 'id')
    op.drop_column('score', 'id')
    # ### end Alembic commands ###
