"""empty message

Revision ID: 247c9e7de059
Revises: None
Create Date: 2015-12-02 15:03:20.582541

"""

# revision identifiers, used by Alembic.
revision = '247c9e7de059'
down_revision = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('units',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('unit_name', sa.String(length=80), nullable=False),
    sa.Column('must_be_whole_number', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('unit_name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=80), nullable=False),
    sa.Column('email', sa.String(length=80), nullable=False),
    sa.Column('password', sa.String(length=128), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('first_name', sa.String(length=30), nullable=True),
    sa.Column('last_name', sa.String(length=30), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('companies',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('company_name', sa.String(length=80), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('company_name')
    )
    op.create_table('item_groups',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('item_group_name', sa.String(length=80), nullable=False),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('is_group', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['parent_id'], ['item_groups.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('item_group_name')
    )
    op.create_table('warehouses',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('warehouse_name', sa.String(length=80), nullable=False),
    sa.Column('company_id', sa.Integer(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('address1', sa.String(length=200), nullable=False),
    sa.Column('address2', sa.String(length=200), nullable=False),
    sa.ForeignKeyConstraint(['company_id'], ['companies.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('address1'),
    sa.UniqueConstraint('address2'),
    sa.UniqueConstraint('warehouse_name')
    )
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('items',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('item_code', sa.String(length=80), nullable=False),
    sa.Column('item_name', sa.String(length=80), nullable=False),
    sa.Column('item_group_id', sa.Integer(), nullable=True),
    sa.Column('default_unit_id', sa.Integer(), nullable=True),
    sa.Column('default_warehouse_id', sa.Integer(), nullable=True),
    sa.Column('description', sa.String(length=80), nullable=False),
    sa.ForeignKeyConstraint(['default_unit_id'], ['units.id'], ),
    sa.ForeignKeyConstraint(['default_warehouse_id'], ['warehouses.id'], ),
    sa.ForeignKeyConstraint(['item_group_id'], ['item_groups.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('description'),
    sa.UniqueConstraint('item_code')
    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('items')
    op.drop_table('roles')
    op.drop_table('warehouses')
    op.drop_table('item_groups')
    op.drop_table('companies')
    op.drop_table('users')
    op.drop_table('units')
    ### end Alembic commands ###
