"""create tables and relations servico

Revision ID: 6861c54421c9
Revises: 0ad953cf53e9
Create Date: 2020-09-05 17:05:10.231646

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6861c54421c9'
down_revision = '0ad953cf53e9'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('servico',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('cliente_id', sa.Integer(), nullable=True),
    sa.Column('valor', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('tempo', sa.Integer(), nullable=True),
    sa.Column('observacao', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['cliente_id'], ['cliente.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('equipamento_servico',
    sa.Column('equipamento_id', sa.Integer(), nullable=True),
    sa.Column('servico_id', sa.Integer(), nullable=True),
    sa.Column('tempo', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['equipamento_id'], ['equipamento.id'], ),
    sa.ForeignKeyConstraint(['servico_id'], ['servico.id'], )
    )
    op.create_table('produto_servico',
    sa.Column('produto_id', sa.Integer(), nullable=True),
    sa.Column('servico_id', sa.Integer(), nullable=True),
    sa.Column('quantidade', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['produto_id'], ['produto.id'], ),
    sa.ForeignKeyConstraint(['servico_id'], ['servico.id'], )
    )
    op.create_table('tipo_servico_servico',
    sa.Column('tipo_servico_id', sa.Integer(), nullable=True),
    sa.Column('servico_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['servico_id'], ['servico.id'], ),
    sa.ForeignKeyConstraint(['tipo_servico_id'], ['tipo_servico.id'], )
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tipo_servico_servico')
    op.drop_table('produto_servico')
    op.drop_table('equipamento_servico')
    op.drop_table('servico')
    # ### end Alembic commands ###
