"""Vendor and part details models added

Revision ID: 4e622fb65953
Revises: 327da2719f0e
Create Date: 2016-01-10 03:37:10.338044

"""

# revision identifiers, used by Alembic.
revision = '4e622fb65953'
down_revision = '327da2719f0e'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy_utils.types.arrow import ArrowType


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('SourcingVendorDetail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('dname', sa.String(), nullable=False),
    sa.Column('currency_code', sa.String(), nullable=False),
    sa.Column('currency_symbol', sa.String(), nullable=False),
    sa.Column('vendor_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vendor_id'], ['SourcingVendor.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('vendor_id')
    )
    op.create_table('VendorElnPartDetail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('package', sa.String(), nullable=False),
    sa.Column('datasheet', sa.String(), nullable=False),
    sa.Column('vpno_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vpno_id'], ['VendorPartNumber.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('vpno_id')
    )
    op.create_table('VendorPartDetail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', ArrowType(), nullable=True),
    sa.Column('updated_at', ArrowType(), nullable=True),
    sa.Column('vqtyavail', sa.Integer(), nullable=True),
    sa.Column('manufacturer', sa.String(), nullable=True),
    sa.Column('mpartno', sa.String(), nullable=True),
    sa.Column('vpartdesc', sa.String(), nullable=True),
    sa.Column('pkgqty', sa.Integer(), nullable=True),
    sa.Column('vpno_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vpno_id'], ['VendorPartNumber.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('vpno_id')
    )
    op.create_table('VendorPrice',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', ArrowType(), nullable=True),
    sa.Column('updated_at', ArrowType(), nullable=True),
    sa.Column('moq', sa.Integer(), nullable=False),
    sa.Column('price', sa.String(), nullable=False),
    sa.Column('oqmultiple', sa.Integer(), nullable=False),
    sa.Column('vpno_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vpno_id'], ['VendorPartNumber.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.alter_column(u'VendorPartMap', 'vendor_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column(u'VendorPartNumber', 'vpmap_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(u'VendorPartNumber', 'vpmap_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column(u'VendorPartMap', 'vendor_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.drop_table('VendorPrice')
    op.drop_table('VendorPartDetail')
    op.drop_table('VendorElnPartDetail')
    op.drop_table('SourcingVendorDetail')
    ### end Alembic commands ###
