"""add uploadfile table

Revision ID: b7302f83d979
Revises: 9b427307a934
Create Date: 2016-12-25 16:22:23.227173

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = 'b7302f83d979'
down_revision = '9b427307a934'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('upload file',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=30), nullable=True),
    sa.Column('apk', sa.String(length=255), nullable=True),
    sa.Column('owner', sa.String(length=20), nullable=True),
    sa.Column('time', sa.DateTime(), nullable=True),
    sa.Column('intro', sa.String(length=1024), nullable=True),
    sa.Column('link', sa.String(length=1024), nullable=True),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_upload file_apk'), 'upload file', ['apk'], unique=False)
    op.create_index(op.f('ix_upload file_count'), 'upload file', ['count'], unique=False)
    op.create_index(op.f('ix_upload file_id'), 'upload file', ['id'], unique=False)
    op.create_index(op.f('ix_upload file_intro'), 'upload file', ['intro'], unique=False)
    op.create_index(op.f('ix_upload file_link'), 'upload file', ['link'], unique=False)
    op.create_index(op.f('ix_upload file_name'), 'upload file', ['name'], unique=False)
    op.create_index(op.f('ix_upload file_owner'), 'upload file', ['owner'], unique=False)
    op.create_index(op.f('ix_upload file_time'), 'upload file', ['time'], unique=False)
    op.add_column(u'users', sa.Column('age', sa.String(length=20), nullable=True))
    op.add_column(u'users', sa.Column('email', sa.String(length=64), nullable=True))
    op.add_column(u'users', sa.Column('gender', sa.String(length=20), nullable=True))
    op.alter_column(u'users', 'access_token',
               existing_type=mysql.VARCHAR(length=1024),
               nullable=True)
    op.alter_column(u'users', 'created',
               existing_type=mysql.DATETIME(),
               nullable=True)
    op.alter_column(u'users', 'name',
               existing_type=mysql.VARCHAR(length=20),
               nullable=True)
    op.alter_column(u'users', 'profile_url',
               existing_type=mysql.VARCHAR(length=1024),
               nullable=True)
    op.alter_column(u'users', 'uid',
               existing_type=mysql.VARCHAR(length=256),
               nullable=True)
    op.alter_column(u'users', 'updated',
               existing_type=mysql.DATETIME(),
               nullable=True)
    op.create_index(op.f('ix_users_access_token'), 'users', ['access_token'], unique=False)
    op.create_index(op.f('ix_users_age'), 'users', ['age'], unique=False)
    op.create_index(op.f('ix_users_created'), 'users', ['created'], unique=False)
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=False)
    op.create_index(op.f('ix_users_gender'), 'users', ['gender'], unique=False)
    op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
    op.create_index(op.f('ix_users_name'), 'users', ['name'], unique=False)
    op.create_index(op.f('ix_users_profile_url'), 'users', ['profile_url'], unique=False)
    op.create_index(op.f('ix_users_uid'), 'users', ['uid'], unique=False)
    op.create_index(op.f('ix_users_updated'), 'users', ['updated'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_users_updated'), table_name='users')
    op.drop_index(op.f('ix_users_uid'), table_name='users')
    op.drop_index(op.f('ix_users_profile_url'), table_name='users')
    op.drop_index(op.f('ix_users_name'), table_name='users')
    op.drop_index(op.f('ix_users_id'), table_name='users')
    op.drop_index(op.f('ix_users_gender'), table_name='users')
    op.drop_index(op.f('ix_users_email'), table_name='users')
    op.drop_index(op.f('ix_users_created'), table_name='users')
    op.drop_index(op.f('ix_users_age'), table_name='users')
    op.drop_index(op.f('ix_users_access_token'), table_name='users')
    op.alter_column(u'users', 'updated',
               existing_type=mysql.DATETIME(),
               nullable=False)
    op.alter_column(u'users', 'uid',
               existing_type=mysql.VARCHAR(length=256),
               nullable=False)
    op.alter_column(u'users', 'profile_url',
               existing_type=mysql.VARCHAR(length=1024),
               nullable=False)
    op.alter_column(u'users', 'name',
               existing_type=mysql.VARCHAR(length=20),
               nullable=False)
    op.alter_column(u'users', 'created',
               existing_type=mysql.DATETIME(),
               nullable=False)
    op.alter_column(u'users', 'access_token',
               existing_type=mysql.VARCHAR(length=1024),
               nullable=False)
    op.drop_column(u'users', 'gender')
    op.drop_column(u'users', 'email')
    op.drop_column(u'users', 'age')
    op.drop_index(op.f('ix_upload file_time'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_owner'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_name'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_link'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_intro'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_id'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_count'), table_name='upload file')
    op.drop_index(op.f('ix_upload file_apk'), table_name='upload file')
    op.drop_table('upload file')
    # ### end Alembic commands ###
