"""Add build queue item reference to the repositorybuild table

Revision ID: 14fe12ade3df
Revises: 5ad999136045
Create Date: 2015-02-12 16:11:57.814645

"""

# revision identifiers, used by Alembic.
revision = '14fe12ade3df'
down_revision = '5ad999136045'

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

def upgrade(tables):
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('repositorybuild', sa.Column('queue_item_id', sa.Integer(), nullable=True))
    op.create_index('repositorybuild_queue_item_id', 'repositorybuild', ['queue_item_id'], unique=False)
    op.create_foreign_key(op.f('fk_repositorybuild_queue_item_id_queueitem'), 'repositorybuild', 'queueitem', ['queue_item_id'], ['id'])
    ### end Alembic commands ###


def downgrade(tables):
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f('fk_repositorybuild_queue_item_id_queueitem'), 'repositorybuild', type_='foreignkey')
    op.drop_index('repositorybuild_queue_item_id', table_name='repositorybuild')
    op.drop_column('repositorybuild', 'queue_item_id')
    ### end Alembic commands ###
