"""empty message

Revision ID: 374bf1119541
Revises: 1227ec5eaf09
Create Date: 2021-10-05 10:45:30.369111

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '374bf1119541'
down_revision = '1227ec5eaf09'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('codigo_postal',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('codigo_postal', sa.Integer(), nullable=False),
    sa.Column('estado', sa.String(length=100), nullable=False),
    sa.Column('municipio', sa.String(length=100), nullable=False),
    sa.Column('ciudad', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('codigo_postal')
    )
    op.create_table('consumo_info',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('consumo_json', sa.JSON(), nullable=False),
    sa.Column('ahorro_json', sa.JSON(), nullable=False),
    sa.Column('info_solar_json', sa.JSON(), nullable=False),
    sa.Column('rinv_inf_json', sa.JSON(), nullable=False),
    sa.Column('rinv_noinf_json', sa.JSON(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_consumo_info_created_at'), 'consumo_info', ['created_at'], unique=False)
    op.create_table('licitacion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('agrupada', sa.Boolean(), nullable=False),
    sa.Column('kwp_inst', sa.Numeric(precision=4, scale=2), nullable=True),
    sa.Column('kw', sa.Numeric(precision=4, scale=2), nullable=True),
    sa.Column('cant', sa.Numeric(precision=4, scale=2), nullable=True),
    sa.Column('activa', sa.Boolean(), nullable=False),
    sa.Column('tipo', sa.String(length=25), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('oferta_venta_asignada', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_licitacion_created_at'), 'licitacion', ['created_at'], unique=False)
    op.create_table('licitacion_publica',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('cog_user_id', sa.String(length=50), nullable=True),
    sa.Column('nombre', sa.String(length=100), nullable=True),
    sa.Column('apellidos', sa.String(length=100), nullable=True),
    sa.Column('email', sa.String(length=120), nullable=True),
    sa.Column('telefono', sa.String(length=10), nullable=True),
    sa.Column('nombre_comercial', sa.String(length=100), nullable=False),
    sa.Column('razon_social', sa.String(length=100), nullable=False),
    sa.Column('rfc', sa.String(length=13), nullable=False),
    sa.Column('nombre_rep_legal', sa.String(length=100), nullable=False),
    sa.Column('ape_paterno_rep_legal', sa.String(length=100), nullable=False),
    sa.Column('ape_materno_rep_legal', sa.String(length=100), nullable=False),
    sa.Column('calle', sa.String(length=100), nullable=False),
    sa.Column('colonia', sa.String(length=100), nullable=False),
    sa.Column('cp_id', sa.Integer(), nullable=True),
    sa.Column('acta_constitutiva_key', sa.String(length=100), nullable=False),
    sa.Column('doc_req1_key', sa.String(length=100), nullable=False),
    sa.Column('doc_req2_key', sa.String(length=100), nullable=False),
    sa.Column('doc_req3_key', sa.String(length=100), nullable=False),
    sa.Column('tiene_rol', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['cp_id'], ['codigo_postal.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('cog_user_id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('user_pending',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('rol_solicitado', sa.String(length=30), nullable=False),
    sa.Column('aceptado', sa.Boolean(), nullable=True),
    sa.Column('fecha_peticion', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_pending_fecha_peticion'), 'user_pending', ['fecha_peticion'], unique=False)
    op.create_table('user_role',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('tipo', sa.String(length=25), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id')
    )
    op.create_table('admin',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['user_role.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('comprador',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('atr', sa.String(length=10), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['user_role.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('gestor',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('codigo', sa.String(length=6), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['user_role.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_gestor_codigo'), 'gestor', ['codigo'], unique=True)
    op.create_table('integrador',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['user_role.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('licitacion_privada',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('comprador_id', sa.Integer(), nullable=False),
    sa.Column('codigo', sa.String(length=6), nullable=True),
    sa.ForeignKeyConstraint(['comprador_id'], ['comprador.id'], ),
    sa.ForeignKeyConstraint(['id'], ['licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_licitacion_privada_codigo'), 'licitacion_privada', ['codigo'], unique=True)
    op.create_table('oferta_licitacion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('licitacion_id', sa.Integer(), nullable=False),
    sa.Column('comprador_id', sa.Integer(), nullable=False),
    sa.Column('gestor_id', sa.Integer(), nullable=True),
    sa.Column('nombre', sa.String(length=100), nullable=False),
    sa.Column('min_wp', sa.Numeric(precision=8, scale=2), nullable=False),
    sa.Column('max_kw', sa.Numeric(precision=8, scale=2), nullable=False),
    sa.Column('kwp', sa.Numeric(precision=8, scale=2), nullable=True),
    sa.Column('kw', sa.Numeric(precision=8, scale=2), nullable=True),
    sa.Column('precio_max', sa.Numeric(precision=12, scale=2), nullable=False),
    sa.Column('direccion', sa.String(length=100), nullable=False),
    sa.Column('colonia', sa.String(length=100), nullable=False),
    sa.Column('cp_id', sa.Integer(), nullable=True),
    sa.Column('latitud', sa.Numeric(precision=7, scale=4), nullable=False),
    sa.Column('longitud', sa.Numeric(precision=7, scale=4), nullable=False),
    sa.Column('status', sa.Integer(), nullable=False),
    sa.Column('aceptada', sa.Boolean(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['comprador_id'], ['comprador.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['cp_id'], ['codigo_postal.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['gestor_id'], ['gestor.id'], ),
    sa.ForeignKeyConstraint(['licitacion_id'], ['licitacion.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_oferta_licitacion_timestamp'), 'oferta_licitacion', ['timestamp'], unique=False)
    op.create_table('dimensionamiento',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('proyecto_ejecutivo_key', sa.String(length=50), nullable=True),
    sa.Column('status_comprador', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['oferta_licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('instalacion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('confirmacion_integrador', sa.Boolean(), nullable=False),
    sa.Column('confirmacion_comprador', sa.Boolean(), nullable=False),
    sa.Column('confirmacion_gestor', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['oferta_licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('oferta_proveedor',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('oferta_id', sa.Integer(), nullable=False),
    sa.Column('integrador_id', sa.Integer(), nullable=False),
    sa.Column('precio', sa.Numeric(precision=8, scale=2), nullable=False),
    sa.Column('asignada', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['integrador_id'], ['integrador.id'], ),
    sa.ForeignKeyConstraint(['oferta_id'], ['oferta_licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('pre_dimensionamiento',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('status_gestor', sa.Boolean(), nullable=False),
    sa.Column('status_comprador', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['oferta_licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('puesta_en_marcha',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('finished_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['oferta_licitacion.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_puesta_en_marcha_finished_at'), 'puesta_en_marcha', ['finished_at'], unique=False)
    op.create_table('adquisicion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('oferta_prov_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['oferta_licitacion.id'], ),
    sa.ForeignKeyConstraint(['oferta_prov_id'], ['oferta_proveedor.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('oferta_prov_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('adquisicion')
    op.drop_index(op.f('ix_puesta_en_marcha_finished_at'), table_name='puesta_en_marcha')
    op.drop_table('puesta_en_marcha')
    op.drop_table('pre_dimensionamiento')
    op.drop_table('oferta_proveedor')
    op.drop_table('instalacion')
    op.drop_table('dimensionamiento')
    op.drop_index(op.f('ix_oferta_licitacion_timestamp'), table_name='oferta_licitacion')
    op.drop_table('oferta_licitacion')
    op.drop_index(op.f('ix_licitacion_privada_codigo'), table_name='licitacion_privada')
    op.drop_table('licitacion_privada')
    op.drop_table('integrador')
    op.drop_index(op.f('ix_gestor_codigo'), table_name='gestor')
    op.drop_table('gestor')
    op.drop_table('comprador')
    op.drop_table('admin')
    op.drop_table('user_role')
    op.drop_index(op.f('ix_user_pending_fecha_peticion'), table_name='user_pending')
    op.drop_table('user_pending')
    op.drop_table('user')
    op.drop_table('licitacion_publica')
    op.drop_index(op.f('ix_licitacion_created_at'), table_name='licitacion')
    op.drop_table('licitacion')
    op.drop_index(op.f('ix_consumo_info_created_at'), table_name='consumo_info')
    op.drop_table('consumo_info')
    op.drop_table('codigo_postal')
    # ### end Alembic commands ###
