"""'init'

Revision ID: 3377f3e6ef65
Revises: 
Create Date: 2017-08-04 09:29:42.836855

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '3377f3e6ef65'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('we_sms_codes',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('wezchina_id', sa.Integer(), nullable=True),
    sa.Column('mobile', sa.String(length=15), nullable=True),
    sa.Column('verify_code', sa.String(length=15), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('client_ip', sa.String(length=20), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=50), nullable=True),
    sa.Column('mobile', sa.String(length=15), nullable=True),
    sa.Column('name', sa.String(length=20), nullable=True),
    sa.Column('sex', sa.String(length=2), nullable=True),
    sa.Column('ethnicity', sa.String(length=255), nullable=True),
    sa.Column('birth', sa.String(length=30), nullable=True),
    sa.Column('id_number', sa.String(length=20), nullable=True),
    sa.Column('id_card_front', sa.Text(), nullable=True),
    sa.Column('authority', sa.String(length=50), nullable=True),
    sa.Column('valid_period_start', sa.String(length=30), nullable=True),
    sa.Column('valid_period_end', sa.String(length=30), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('avatar', sa.Text(), nullable=True),
    sa.Column('intro', sa.String(length=200), nullable=True),
    sa.Column('email', sa.String(length=30), nullable=True),
    sa.Column('origo', sa.String(length=255), nullable=True),
    sa.Column('country', sa.String(length=255), nullable=True),
    sa.Column('province', sa.String(length=50), nullable=True),
    sa.Column('city', sa.String(length=50), nullable=True),
    sa.Column('id_check_num', sa.Integer(), nullable=True),
    sa.Column('position', sa.String(length=50), nullable=True),
    sa.Column('organization', sa.String(length=50), nullable=True),
    sa.Column('manual_status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_we_users_mobile'), 'we_users', ['mobile'], unique=True)
    op.create_table('we_zchina_modules',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('name', sa.String(length=50), nullable=True),
    sa.Column('displayname', sa.String(length=100), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('type', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_product_services',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('orig_solution_id', sa.String(length=36), nullable=True),
    sa.Column('module_id', sa.String(length=36), nullable=True),
    sa.Column('zchina_user_id', sa.String(length=36), nullable=True),
    sa.Column('plat_id', sa.String(length=36), nullable=True),
    sa.Column('start_at', sa.String(length=30), nullable=True),
    sa.Column('end_at', sa.String(length=30), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_products',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('modules_id', sa.Integer(), nullable=True),
    sa.Column('type', sa.Integer(), nullable=True),
    sa.Column('sort', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=20), nullable=True),
    sa.Column('displayname', sa.String(length=20), nullable=True),
    sa.Column('description', sa.String(length=200), nullable=True),
    sa.Column('intro', sa.String(length=200), nullable=True),
    sa.Column('price', sa.String(length=20), nullable=True),
    sa.Column('forsale', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_solutions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('config', sa.Text(), nullable=True),
    sa.Column('type', sa.Integer(), nullable=True),
    sa.Column('sort', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=20), nullable=True),
    sa.Column('displayname', sa.String(length=20), nullable=True),
    sa.Column('description', sa.String(length=200), nullable=True),
    sa.Column('intro', sa.String(length=200), nullable=True),
    sa.Column('price', sa.String(length=20), nullable=True),
    sa.Column('forsale', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchinas',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=64), nullable=True),
    sa.Column('name', sa.String(length=60), nullable=True),
    sa.Column('manager', sa.String(length=60), nullable=True),
    sa.Column('domain', sa.String(length=60), nullable=True),
    sa.Column('start_at', sa.Integer(), nullable=True),
    sa.Column('end_at', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_module_functions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('module_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=20), nullable=True),
    sa.Column('displayname', sa.String(length=20), nullable=True),
    sa.Column('description', sa.String(length=200), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['module_id'], ['we_zchina_modules.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=64), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('wezchina_id', sa.Integer(), nullable=True),
    sa.Column('real_name', sa.String(length=30), nullable=True),
    sa.Column('mobile', sa.String(length=20), nullable=True),
    sa.Column('balance', sa.Float(precision=0.0), nullable=True),
    sa.Column('nickname', sa.String(length=30), nullable=True),
    sa.Column('wx_open_id', sa.String(length=255), nullable=True),
    sa.Column('user_type_id', sa.Integer(), nullable=True),
    sa.Column('zchina_cert', sa.Integer(), nullable=True),
    sa.Column('zchian_auth', sa.Integer(), nullable=True),
    sa.Column('solutions_id', sa.Integer(), nullable=True),
    sa.Column('active', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['we_users.id'], ),
    sa.ForeignKeyConstraint(['wezchina_id'], ['we_zchinas.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_article_cates',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=60), nullable=True),
    sa.Column('en_name', sa.String(length=60), nullable=True),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_product_functions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('module_function_id', sa.Integer(), nullable=True),
    sa.Column('type', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=20), nullable=True),
    sa.Column('displayname', sa.String(length=20), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('intro', sa.Text(), nullable=True),
    sa.Column('price', sa.String(length=20), nullable=True),
    sa.Column('forsale', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['module_function_id'], ['we_zchina_module_functions.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['we_zchina_products.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_solution_services',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('solution_id', sa.Integer(), nullable=True),
    sa.Column('config', sa.Text(), nullable=True),
    sa.Column('plat_id', sa.Integer(), nullable=True),
    sa.Column('type', sa.Integer(), nullable=True),
    sa.Column('start_at', sa.Integer(), nullable=True),
    sa.Column('end_at', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['solution_id'], ['we_zchina_solutions.id'], ),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_user_auths',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=60), nullable=True),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('id_num', sa.String(length=20), nullable=True),
    sa.Column('name', sa.String(length=20), nullable=True),
    sa.Column('ID_photo_front', sa.String(length=255), nullable=True),
    sa.Column('ID_photo_back', sa.String(length=255), nullable=True),
    sa.Column('active', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_user_certs',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=64), nullable=True),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.Column('address', sa.String(length=200), nullable=True),
    sa.Column('nature', sa.String(length=255), nullable=True),
    sa.Column('license', sa.String(length=255), nullable=True),
    sa.Column('authorization', sa.String(length=255), nullable=True),
    sa.Column('active', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_user_logs',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('user_operation', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_user_types',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('user_type_id', sa.Integer(), nullable=True),
    sa.Column('user_type', sa.String(length=20), nullable=True),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_articles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=64), nullable=True),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('cate_id', sa.Integer(), nullable=True),
    sa.Column('title', sa.String(length=255), nullable=True),
    sa.Column('status', sa.SmallInteger(), nullable=True),
    sa.Column('href', sa.String(length=255), nullable=True),
    sa.Column('source_url', sa.String(length=120), nullable=True),
    sa.Column('cover', sa.String(length=255), nullable=True),
    sa.Column('views', sa.Integer(), nullable=True),
    sa.Column('summary', sa.String(length=255), nullable=True),
    sa.Column('content', sa.Text(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['cate_id'], ['we_zchina_article_cates.id'], ),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('we_zchina_product_function_services',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('weid', sa.String(length=36), nullable=True),
    sa.Column('orig_product_value_id', sa.String(length=50), nullable=True),
    sa.Column('type', sa.Integer(), nullable=True),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('function_id', sa.Integer(), nullable=True),
    sa.Column('module_function_id', sa.Integer(), nullable=True),
    sa.Column('zchina_user_id', sa.Integer(), nullable=True),
    sa.Column('plat_id', sa.Integer(), nullable=True),
    sa.Column('start_at', sa.Integer(), nullable=True),
    sa.Column('end_at', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['function_id'], ['we_zchina_product_functions.id'], ),
    sa.ForeignKeyConstraint(['module_function_id'], ['we_zchina_module_functions.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['we_zchina_products.id'], ),
    sa.ForeignKeyConstraint(['zchina_user_id'], ['we_zchina_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('we_zchina_product_function_services')
    op.drop_table('we_zchina_articles')
    op.drop_table('we_zchina_user_types')
    op.drop_table('we_zchina_user_logs')
    op.drop_table('we_zchina_user_certs')
    op.drop_table('we_zchina_user_auths')
    op.drop_table('we_zchina_solution_services')
    op.drop_table('we_zchina_product_functions')
    op.drop_table('we_zchina_article_cates')
    op.drop_table('we_zchina_users')
    op.drop_table('we_zchina_module_functions')
    op.drop_table('we_zchinas')
    op.drop_table('we_zchina_solutions')
    op.drop_table('we_zchina_products')
    op.drop_table('we_zchina_product_services')
    op.drop_table('we_zchina_modules')
    op.drop_index(op.f('ix_we_users_mobile'), table_name='we_users')
    op.drop_table('we_users')
    op.drop_table('we_sms_codes')
    # ### end Alembic commands ###
