"""add rank to issue

Revision ID: 4d5027f9faac
Revises: 6d3439e14660
Create Date: 2019-03-23 13:37:47.267698

"""
from alembic import op
import sqlalchemy as sa
from pabu.tools import get_table

# revision identifiers, used by Alembic.
revision = '4d5027f9faac'
down_revision = '6d3439e14660'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('issues', sa.Column('rank', sa.Integer(), nullable=True))

    issues = get_table(op.get_bind(), 'issues')
    op.execute(issues.update().values(rank = issues.c.id))

    # ### end Alembic commands ###


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