"""Added hopengine models for hops and offers and distributors - everything but specs and attributes

Revision ID: 51a83e459c10
Revises: 4fcdc1453392
Create Date: 2013-10-06 17:57:18.636850

"""

# revision identifiers, used by Alembic.
revision = '51a83e459c10'
down_revision = '4fcdc1453392'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('farm',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=500), nullable=True),
    sa.Column('country', sa.String(length=2), nullable=True),
    sa.Column('url', sa.String(length=1000), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('hop',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('variety', sa.String(length=500), nullable=True),
    sa.Column('country', sa.String(length=2), nullable=True),
    sa.Column('macro_classification', sa.SmallInteger(), nullable=True),
    sa.Column('description', sa.String(length=1000), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('variety','country', name='variety_country_unique')
    )
    op.create_table('unit_of_measurement',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=500), nullable=True),
    sa.Column('symbol', sa.String(length=20), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('distributor',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=500), nullable=True),
    sa.Column('country', sa.String(length=2), nullable=True),
    sa.Column('url', sa.String(length=1000), nullable=True),
    sa.Column('id_farm', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['id_farm'], ['farm.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('offer',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sku', sa.String(length=500), nullable=True),
    sa.Column('url', sa.String(length=1000), nullable=True),
    sa.Column('form', sa.String(length=500), nullable=True),
    sa.Column('packaging', sa.String(length=500), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('max_order', sa.Float(), nullable=True),
    sa.Column('min_order', sa.Float(), nullable=True),
    sa.Column('pre_sale', sa.Boolean(), nullable=True),
    sa.Column('quantity', sa.Float(), nullable=True),
    sa.Column('organic', sa.Boolean(), nullable=True),
    sa.Column('region', sa.String(length=500), nullable=True),
    sa.Column('id_hop', sa.Integer(), nullable=True),
    sa.Column('id_distributor', sa.Integer(), nullable=True),
    sa.Column('id_farm', sa.Integer(), nullable=True),
    sa.Column('id_unit', sa.Integer(), nullable=True),
    sa.Column('id_currency', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['id_currency'], ['unit_of_measurement.id'], ),
    sa.ForeignKeyConstraint(['id_distributor'], ['distributor.id'], ),
    sa.ForeignKeyConstraint(['id_farm'], ['farm.id'], ),
    sa.ForeignKeyConstraint(['id_hop'], ['hop.id'], ),
    sa.ForeignKeyConstraint(['id_unit'], ['unit_of_measurement.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('price_break',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('quantity', sa.Float(), nullable=True),
    sa.Column('price', sa.Float(), nullable=True),
    sa.Column('id_offer', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['id_offer'], ['offer.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('price_break')
    op.drop_table('offer')
    op.drop_table('distributor')
    op.drop_table('unit_of_measurement')
    op.drop_table('hop')
    op.drop_table('farm')
    ### end Alembic commands ###
