"""Added tariff

Revision ID: 4dbaa3104f4
Revises: 1d6f96d1df
Create Date: 2015-05-27 16:00:09.343862

"""

# revision identifiers, used by Alembic.
revision = '4dbaa3104f4'
down_revision = '1d6f96d1df'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_account():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tariff',
    sa.Column('tariff_id', sa.Integer(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('currency', sa.String(length=3), nullable=True),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('deleted', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('mutable', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['parent_id'], ['tariff.tariff_id'], ),
    sa.PrimaryKeyConstraint('tariff_id')
    )
    op.create_table('service_price',
    sa.Column('service_id', sa.String(length=32), nullable=False),
    sa.Column('price', sa.DECIMAL(precision=20, scale=6), nullable=True),
    sa.Column('tariff_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['tariff_id'], ['tariff.tariff_id'], ),
    sa.PrimaryKeyConstraint('service_id', 'tariff_id')
    )
    op.create_table('tariff_history',
    sa.Column('history_id', sa.Integer(), nullable=False),
    sa.Column('event', sa.String(length=8), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('tariff_id', sa.Integer(), nullable=True),
    sa.Column('customer_id', sa.Integer(), nullable=True),
    sa.Column('date', sa.DateTime(), nullable=True),
    sa.Column('snapshot', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['customer_id'], ['customer.customer_id'], ),
    sa.ForeignKeyConstraint(['tariff_id'], ['tariff.tariff_id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.user_id'], ),
    sa.PrimaryKeyConstraint('history_id')
    )
    op.create_table('tariff_localization',
    sa.Column('language', sa.String(length=2), nullable=False),
    sa.Column('parent_id', sa.Integer(), nullable=False),
    sa.Column('localized_name', sa.String(length=254), nullable=True),
    sa.ForeignKeyConstraint(['parent_id'], ['tariff.tariff_id'], ),
    sa.PrimaryKeyConstraint('language', 'parent_id'),
    sa.UniqueConstraint('localized_name', 'language', name='uix_tariff_localization')
    )
    ### end Alembic commands ###


def downgrade_account():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tariff_localization')
    op.drop_table('tariff_history')
    op.drop_table('service_price')
    op.drop_table('tariff')
    ### end Alembic commands ###


def upgrade_fitter():
    pass


def downgrade_fitter():
    pass

