"""init database

Revision ID: d79eac41605c
Revises: None
Create Date: 2016-03-18 11:54:25.157000

"""

# revision identifiers, used by Alembic.
revision = 'd79eac41605c'
down_revision = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('MyGasStation',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=30), nullable=True),
                    sa.Column('area', sa.String(length=30), nullable=True),
                    sa.Column('areaname', sa.String(length=30), nullable=True),
                    sa.Column('address', sa.String(length=30), nullable=True),
                    sa.Column('brandname', sa.String(length=30), nullable=True),
                    sa.Column('type', sa.String(length=30), nullable=True),
                    sa.Column('discount', sa.String(length=30), nullable=True),
                    sa.Column('exhaust', sa.String(length=30), nullable=True),
                    sa.Column('position', sa.String(length=30), nullable=True),
                    sa.Column('price', sa.String(length=30), nullable=True),
                    sa.Column('gastprice', sa.String(length=30), nullable=True),
                    sa.Column('fwlsmc', sa.String(length=30), nullable=True),
                    sa.Column('lat', sa.Float(), nullable=True),
                    sa.Column('lon', sa.Float(), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('MyUser',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('phone_number', sa.String(length=20), nullable=True),
                    sa.Column('password_hash', sa.String(length=128), nullable=True),
                    sa.Column('nick', sa.String(length=64), nullable=True),
                    sa.Column('sex', sa.Boolean(), nullable=True),
                    sa.Column('age', sa.String(length=5), nullable=True),
                    sa.Column('member_since', sa.DateTime(), nullable=True),
                    sa.Column('avatar', sa.String(length=100), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('MyCar',
                    sa.Column('license_plate_number', sa.String(length=30), nullable=False),
                    sa.Column('brand', sa.String(length=20), nullable=True),
                    sa.Column('car', sa.String(length=30), nullable=True),
                    sa.Column('model', sa.String(length=30), nullable=True),
                    sa.Column('engine_number', sa.String(length=30), nullable=True),
                    sa.Column('milege', sa.Float(), nullable=True),
                    sa.Column('remaining_oil', sa.Float(), nullable=True),
                    sa.Column('engine_statu', sa.Boolean(), nullable=True),
                    sa.Column('antomative_lighting_statu', sa.Boolean(), nullable=True),
                    sa.Column('speed_changing_box_statu', sa.Boolean(), nullable=True),
                    sa.Column('car_location', sa.String(length=30), nullable=True),
                    sa.Column('registration_date', sa.DateTime(), nullable=True),
                    sa.Column('img', sa.String(length=30), nullable=True),
                    sa.Column('price', sa.String(length=30), nullable=True),
                    sa.Column('displacement', sa.String(length=30), nullable=True),
                    sa.Column('oil_consumption', sa.String(length=30), nullable=True),
                    sa.Column('speed_changing_box', sa.String(length=30), nullable=True),
                    sa.Column('car_type', sa.String(length=30), nullable=True),
                    sa.Column('body_structure', sa.String(length=30), nullable=True),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(['user_id'], ['MyUser.id'], ),
                    sa.PrimaryKeyConstraint('license_plate_number')
                    )
    op.create_index(op.f('ix_MyCar_brand'), 'MyCar', ['brand'], unique=False)
    op.create_index(op.f('ix_MyCar_car'), 'MyCar', ['car'], unique=False)
    op.create_table('MyRefuelOrder',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('order_time', sa.DateTime(), nullable=True),
                    sa.Column('refuel_type', sa.String(length=20), nullable=True),
                    sa.Column('refuel_amount', sa.String(length=10), nullable=True),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.Column('gas_station_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(['gas_station_id'], ['MyGasStation.id'], ),
                    sa.ForeignKeyConstraint(['user_id'], ['MyUser.id'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('MyPeccancy',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('peccancy_action', sa.String(length=50), nullable=True),
                    sa.Column('peccancy_address', sa.String(length=30), nullable=True),
                    sa.Column('peccancy_time', sa.DateTime(), nullable=True),
                    sa.Column('fine', sa.Integer(), nullable=True),
                    sa.Column('deduct_point', sa.Integer(), nullable=True),
                    sa.Column('query_time', sa.DateTime(), nullable=True),
                    sa.Column('car_id', sa.String(length=30), nullable=True),
                    sa.ForeignKeyConstraint(['car_id'], ['MyCar.license_plate_number'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('MyPeccancy')
    op.drop_table('MyRefuelOrder')
    op.drop_index(op.f('ix_MyCar_car'), table_name='MyCar')
    op.drop_index(op.f('ix_MyCar_brand'), table_name='MyCar')
    op.drop_table('MyCar')
    op.drop_table('MyUser')
    op.drop_table('MyGasStation')
    ### end Alembic commands ###
