"""Change build queue reference from foreign key to an id.

Revision ID: 707d5191eda
Revises: 4ef04c61fcf9
Create Date: 2015-02-23 12:36:33.814528

"""

# revision identifiers, used by Alembic.
revision = '707d5191eda'
down_revision = '4ef04c61fcf9'

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_id', sa.String(length=255), nullable=True))
    op.create_index('repositorybuild_queue_id', 'repositorybuild', ['queue_id'], unique=False)
    op.drop_constraint(u'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 ###


def downgrade(tables):
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('repositorybuild', sa.Column('queue_item_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.create_foreign_key(u'fk_repositorybuild_queue_item_id_queueitem', 'repositorybuild', 'queueitem', ['queue_item_id'], ['id'])
    op.create_index('repositorybuild_queue_item_id', 'repositorybuild', ['queue_item_id'], unique=False)
    op.drop_index('repositorybuild_queue_id', table_name='repositorybuild')
    op.drop_column('repositorybuild', 'queue_id')
    ### end Alembic commands ###
