"""empty message

Revision ID: 047faefedcf8
Revises: 3656ed1b714c
Create Date: 2021-06-23 23:57:48.975334

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

# revision identifiers, used by Alembic.
revision = '047faefedcf8'
down_revision = '3656ed1b714c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('Assets',
    sa.Column('assetid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('assetname', sa.String(length=100), nullable=True),
    sa.Column('category', sa.String(length=100), nullable=True),
    sa.Column('make', sa.String(length=100), nullable=True),
    sa.Column('model', sa.String(length=100), nullable=True),
    sa.Column('serialno', sa.String(length=100), nullable=True),
    sa.Column('location', sa.String(length=100), nullable=True),
    sa.Column('intallationdate', sa.DateTime(), nullable=True),
    sa.Column('assetcode', sa.String(length=100), nullable=True),
    sa.Column('status', sa.String(length=100), nullable=True),
    sa.Column('statuschangedate', sa.DateTime(), nullable=True),
    sa.Column('categoryid', sa.Integer(), nullable=True),
    sa.Column('locationid', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('assetid')
    )
    op.create_table('Category',
    sa.Column('categoryid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('categoryname', sa.String(length=100), nullable=True),
    sa.Column('parentid', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('categoryid')
    )
    op.create_table('Fuelgate',
    sa.Column('fuelid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('vehicleno', sa.String(length=100), nullable=True),
    sa.Column('slipno', sa.String(length=100), nullable=True),
    sa.Column('challanno', sa.String(length=100), nullable=True),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.Column('fueltime', sa.DateTime(), nullable=True),
    sa.Column('vehicleid', sa.Integer(), nullable=True),
    sa.Column('fuelslipno', sa.String(length=100), nullable=True),
    sa.Column('username', sa.String(length=100), nullable=True),
    sa.Column('slipid', sa.Integer(), nullable=True),
    sa.Column('transporter', sa.String(length=100), nullable=True),
    sa.Column('transporterid', sa.Integer(), nullable=True),
    sa.Column('location', sa.String(length=100), nullable=True),
    sa.Column('locationid', sa.Integer(), nullable=True),
    sa.Column('wheeler', sa.Integer(), nullable=True),
    sa.Column('driver', sa.String(length=100), nullable=True),
    sa.Column('driverid', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('fuelid')
    )
    op.create_table('Outgate',
    sa.Column('challanid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('slipno', sa.String(length=100), nullable=True),
    sa.Column('slipid', sa.Integer(), nullable=True),
    sa.Column('vehicleno', sa.String(length=100), nullable=True),
    sa.Column('driver', sa.String(length=100), nullable=True),
    sa.Column('driverid', sa.Integer(), nullable=True),
    sa.Column('loading', sa.String(length=100), nullable=True),
    sa.Column('destination', sa.String(length=100), nullable=True),
    sa.Column('challanno', sa.String(length=100), nullable=True),
    sa.Column('gross', sa.Integer(), nullable=True),
    sa.Column('tare', sa.Integer(), nullable=True),
    sa.Column('net', sa.Integer(), nullable=True),
    sa.Column('passdate', sa.DateTime(), nullable=True),
    sa.Column('passgate', sa.String(length=50), nullable=True),
    sa.Column('sliptime', sa.DateTime(), nullable=True),
    sa.Column('challantime', sa.DateTime(), nullable=True),
    sa.Column('printtime', sa.DateTime(), nullable=True),
    sa.Column('material', sa.String(length=50), nullable=True),
    sa.Column('weightbridge', sa.String(length=50), nullable=True),
    sa.Column('vehicleid', sa.Integer(), nullable=True),
    sa.Column('locationid', sa.Integer(), nullable=True),
    sa.Column('username', sa.String(length=50), nullable=True),
    sa.Column('tranporterid', sa.Integer(), nullable=True),
    sa.Column('transporter', sa.String(length=50), nullable=True),
    sa.Column('challannet', sa.Integer(), nullable=True),
    sa.Column('grosswbid', sa.Integer(), nullable=True),
    sa.Column('grosswb', sa.String(length=50), nullable=True),
    sa.Column('tarewb', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('challanid')
    )
    op.create_table('Rfidtag',
    sa.Column('rfid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('rfno', sa.String(length=100), nullable=True),
    sa.Column('isactive', sa.Boolean(create_constraint=100), nullable=True),
    sa.Column('issuedate', sa.DateTime(), nullable=True),
    sa.Column('vehicleno', sa.String(length=4), nullable=True),
    sa.Column('vehicleid', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('rfid')
    )
    op.create_table('blacklist_tokens',
    sa.Column('userid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('token', sa.String(length=500), nullable=False),
    sa.Column('blacklisted_on', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('userid'),
    sa.UniqueConstraint('token')
    )
    op.create_table('owner',
    sa.Column('ownerid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('ownername', sa.String(length=50), nullable=True),
    sa.Column('address1', sa.String(length=50), nullable=True),
    sa.Column('address2', sa.String(length=50), nullable=True),
    sa.Column('pan', sa.String(length=50), nullable=True),
    sa.Column('aadhar', sa.String(length=50), nullable=True),
    sa.Column('mobile', sa.String(length=50), nullable=True),
    sa.Column('gst', sa.String(length=50), nullable=True),
    sa.Column('startdate', sa.DateTime(), nullable=True),
    sa.Column('enddate', sa.DateTime(), nullable=True),
    sa.Column('dlno', sa.String(length=50), nullable=True),
    sa.Column('isactive', sa.Boolean(), server_default='true', nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('statuschangedate', sa.DateTime(), nullable=True),
    sa.Column('stateid', sa.Integer(), nullable=True),
    sa.Column('state', sa.String(length=50), nullable=True),
    sa.Column('pincode', sa.String(length=50), nullable=True),
    sa.Column('bankname', sa.String(length=50), nullable=True),
    sa.Column('accountno', sa.String(length=50), nullable=True),
    sa.Column('ifsc', sa.String(length=50), nullable=True),
    sa.Column('transportercode', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('ownerid')
    )
    op.create_table('weightbridge',
    sa.Column('wbid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('wbname', sa.String(length=100), nullable=False),
    sa.Column('locationid', sa.Integer(), nullable=True),
    sa.Column('location', sa.String(length=50), nullable=True),
    sa.Column('capacity', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('wbid')
    )
    op.drop_table('varpassdate')
    op.drop_table('rfidtag')
    op.drop_table('category')
    op.drop_index('UQ_RolePerm_RoleId_PermKey', table_name='RolePermissions')
    op.drop_table('RolePermissions')
    op.drop_table('outgate')
    op.drop_table('oldowners')
    op.drop_table('assets')
    op.drop_table('test_ingate')
    op.drop_table('Languages')
    op.drop_table('fuelmaster')
    op.drop_table('fuelgate')
    op.drop_table('owners')
    op.drop_table('weighbridge')
    op.drop_table('oldvehiclelist')
    op.drop_table('company')
    op.drop_table('test_outgate')
    op.drop_index('IX_UserRoles_RoleId_UserId', table_name='UserRoles')
    op.drop_index('UQ_UserRoles_UserId_RoleId', table_name='UserRoles')
    op.drop_table('UserRoles')
    op.drop_table('Roles')
    op.drop_index('IX_Exceptions_App_Del_Cre', table_name='Exceptions')
    op.drop_index('IX_Exceptions_GUID_App_Del_Cre', table_name='Exceptions')
    op.drop_index('IX_Exceptions_Hash_App_Cre_Del', table_name='Exceptions')
    op.drop_table('Exceptions')
    op.drop_table('users_app')
    op.drop_index('IX_UserPref_UID_PrefType_Name', table_name='userpreferences')
    op.drop_table('userpreferences')
    op.add_column('UserPermissions', sa.Column('granted', sa.Boolean(), server_default='True', nullable=False))
    op.add_column('UserPermissions', sa.Column('permissionkey', sa.String(length=100), nullable=True))
    op.add_column('UserPermissions', sa.Column('userid', sa.Integer(), nullable=False))
    op.add_column('UserPermissions', sa.Column('userpermissionid', sa.Integer(), autoincrement=True, nullable=False))
    op.drop_index('UQ_UserPerm_UserId_PermKey', table_name='UserPermissions')
    op.drop_constraint('FK_UserPermissions_UserId', 'UserPermissions', type_='foreignkey')
    op.drop_column('UserPermissions', 'PermissionKey')
    op.drop_column('UserPermissions', 'UserId')
    op.drop_column('UserPermissions', 'Granted')
    op.drop_column('UserPermissions', 'UserPermissionId')
    op.alter_column('Users', 'DisplayName',
               existing_type=sa.VARCHAR(length=100),
               nullable=True)
    op.alter_column('Users', 'InsertDate',
               existing_type=postgresql.TIMESTAMP(),
               nullable=True)
    op.alter_column('Users', 'InsertUserId',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('Users', 'IsActive',
               existing_type=sa.SMALLINT(),
               nullable=True,
               existing_server_default=sa.text('1'))
    op.alter_column('Users', 'PasswordHash',
               existing_type=sa.VARCHAR(length=86),
               nullable=True)
    op.alter_column('Users', 'PasswordSalt',
               existing_type=sa.VARCHAR(length=10),
               nullable=True)
    op.alter_column('Users', 'Source',
               existing_type=sa.VARCHAR(length=4),
               nullable=True)
    op.alter_column('Users', 'UserId',
               existing_type=sa.INTEGER(),
               server_default=None,
               existing_nullable=False,
               autoincrement=True)
    op.alter_column('Users', 'Username',
               existing_type=sa.VARCHAR(length=100),
               nullable=True)
    op.alter_column('drivers', 'driverid',
               existing_type=sa.BIGINT(),
               server_default=None,
               existing_nullable=False,
               autoincrement=True)
    op.add_column('ingate', sa.Column('fuelperator', sa.String(length=50), nullable=True))
    op.alter_column('ingate', 'slipid',
               existing_type=sa.BIGINT(),
               server_default=None,
               existing_nullable=False,
               autoincrement=True)
    op.drop_constraint('uq_in_slipno', 'ingate', type_='unique')
    op.drop_column('ingate', 'fueloperator')
    op.alter_column('locations', 'locationid',
               existing_type=sa.INTEGER(),
               server_default=None,
               existing_nullable=False,
               autoincrement=True)
    op.add_column('railwaysiding', sa.Column('challnno', sa.String(length=50), nullable=True))
    op.alter_column('railwaysiding', 'entryid',
               existing_type=sa.BIGINT(),
               server_default=None,
               existing_nullable=False,
               autoincrement=True)
    op.drop_constraint('uq_rail_challanno', 'railwaysiding', type_='unique')
    op.drop_column('railwaysiding', 'wbdatetime')
    op.drop_column('railwaysiding', 'challanno')
    op.drop_column('railwaysiding', 'userexit')
    op.add_column('vehicles', sa.Column('address', sa.String(length=50), nullable=True))
    op.add_column('vehicles', sa.Column('contact', sa.String(length=50), nullable=True))
    op.add_column('vehicles', sa.Column('craetedate', sa.DateTime(), nullable=True))
    op.add_column('vehicles', sa.Column('owner', sa.String(length=50), nullable=True))
    op.add_column('vehicles', sa.Column('ownership', sa.Boolean(), server_default='false', nullable=True))
    op.alter_column('vehicles', 'vehicleid',
               existing_type=sa.INTEGER(),
               server_default=None,
               existing_nullable=False,
               autoincrement=True)
    op.drop_column('vehicles', 'engine')
    op.drop_column('vehicles', 'vownership')
    op.drop_column('vehicles', 'rfid')
    op.drop_column('vehicles', 'vaddress')
    op.drop_column('vehicles', 'gpsno')
    op.drop_column('vehicles', 'createdate')
    op.drop_column('vehicles', 'gpsdate')
    op.drop_column('vehicles', 'modelno')
    op.drop_column('vehicles', 'vcontact')
    op.drop_column('vehicles', 'vowner')
    op.drop_column('vehicles', 'imeino')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('vehicles', sa.Column('imeino', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('vowner', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('vcontact', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('modelno', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('gpsdate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('createdate', sa.DATE(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('gpsno', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('vaddress', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('rfid', sa.BIGINT(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('vownership', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('vehicles', sa.Column('engine', sa.TEXT(), autoincrement=False, nullable=True))
    op.alter_column('vehicles', 'vehicleid',
               existing_type=sa.INTEGER(),
               server_default=sa.Identity(always=True, start=2001, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1),
               existing_nullable=False,
               autoincrement=True)
    op.drop_column('vehicles', 'ownership')
    op.drop_column('vehicles', 'owner')
    op.drop_column('vehicles', 'craetedate')
    op.drop_column('vehicles', 'contact')
    op.drop_column('vehicles', 'address')
    op.add_column('railwaysiding', sa.Column('userexit', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('railwaysiding', sa.Column('challanno', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('railwaysiding', sa.Column('wbdatetime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    op.create_unique_constraint('uq_rail_challanno', 'railwaysiding', ['challanno'])
    op.alter_column('railwaysiding', 'entryid',
               existing_type=sa.BIGINT(),
               server_default=sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1),
               existing_nullable=False,
               autoincrement=True)
    op.drop_column('railwaysiding', 'challnno')
    op.alter_column('locations', 'locationid',
               existing_type=sa.INTEGER(),
               server_default=sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1),
               existing_nullable=False,
               autoincrement=True)
    op.add_column('ingate', sa.Column('fueloperator', sa.TEXT(), autoincrement=False, nullable=True))
    op.create_unique_constraint('uq_in_slipno', 'ingate', ['slipno'])
    op.alter_column('ingate', 'slipid',
               existing_type=sa.BIGINT(),
               server_default=sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1),
               existing_nullable=False,
               autoincrement=True)
    op.drop_column('ingate', 'fuelperator')
    op.alter_column('drivers', 'driverid',
               existing_type=sa.BIGINT(),
               server_default=sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1),
               existing_nullable=False,
               autoincrement=True)
    op.alter_column('Users', 'Username',
               existing_type=sa.VARCHAR(length=100),
               nullable=False)
    op.alter_column('Users', 'UserId',
               existing_type=sa.INTEGER(),
               server_default=sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1),
               existing_nullable=False,
               autoincrement=True)
    op.alter_column('Users', 'Source',
               existing_type=sa.VARCHAR(length=4),
               nullable=False)
    op.alter_column('Users', 'PasswordSalt',
               existing_type=sa.VARCHAR(length=10),
               nullable=False)
    op.alter_column('Users', 'PasswordHash',
               existing_type=sa.VARCHAR(length=86),
               nullable=False)
    op.alter_column('Users', 'IsActive',
               existing_type=sa.SMALLINT(),
               nullable=False,
               existing_server_default=sa.text('1'))
    op.alter_column('Users', 'InsertUserId',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('Users', 'InsertDate',
               existing_type=postgresql.TIMESTAMP(),
               nullable=False)
    op.alter_column('Users', 'DisplayName',
               existing_type=sa.VARCHAR(length=100),
               nullable=False)
    op.add_column('UserPermissions', sa.Column('UserPermissionId', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False))
    op.add_column('UserPermissions', sa.Column('Granted', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False))
    op.add_column('UserPermissions', sa.Column('UserId', sa.INTEGER(), autoincrement=False, nullable=False))
    op.add_column('UserPermissions', sa.Column('PermissionKey', sa.VARCHAR(length=100), autoincrement=False, nullable=False))
    op.create_foreign_key('FK_UserPermissions_UserId', 'UserPermissions', 'Users', ['UserId'], ['UserId'])
    op.create_index('UQ_UserPerm_UserId_PermKey', 'UserPermissions', ['UserId', 'PermissionKey'], unique=True)
    op.drop_column('UserPermissions', 'userpermissionid')
    op.drop_column('UserPermissions', 'userid')
    op.drop_column('UserPermissions', 'permissionkey')
    op.drop_column('UserPermissions', 'granted')
    op.create_table('userpreferences',
    sa.Column('UserPreferenceId', sa.INTEGER(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('UserId', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('PreferenceType', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
    sa.Column('Name', sa.VARCHAR(length=200), autoincrement=False, nullable=False),
    sa.Column('Value', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('UserPreferenceId', name='PK_UserPreferences')
    )
    op.create_index('IX_UserPref_UID_PrefType_Name', 'userpreferences', ['UserId', 'PreferenceType', 'Name'], unique=True)
    op.create_table('users_app',
    sa.Column('id', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('user_name', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('password', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True),
    sa.Column('display_name', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('create_date', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('public_id', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('admin', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='users_pkey')
    )
    op.create_table('Exceptions',
    sa.Column('Id', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('GUID', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('ApplicationName', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
    sa.Column('MachineName', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
    sa.Column('CreationDate', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('Type', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
    sa.Column('IsProtected', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False),
    sa.Column('Host', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('Url', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
    sa.Column('HTTPMethod', sa.VARCHAR(length=10), autoincrement=False, nullable=True),
    sa.Column('IPAddress', sa.VARCHAR(length=40), autoincrement=False, nullable=True),
    sa.Column('Source', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('Message', sa.VARCHAR(length=1000), autoincrement=False, nullable=True),
    sa.Column('Detail', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('StatusCode', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('SQL', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('DeletionDate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('FullJson', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('ErrorHash', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('DuplicateCount', sa.INTEGER(), server_default=sa.text('1'), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('Id', name='PK_Exceptions')
    )
    op.create_index('IX_Exceptions_Hash_App_Cre_Del', 'Exceptions', ['ErrorHash', 'ApplicationName', 'CreationDate', 'DeletionDate'], unique=False)
    op.create_index('IX_Exceptions_GUID_App_Del_Cre', 'Exceptions', ['GUID', 'ApplicationName', 'DeletionDate', 'CreationDate'], unique=False)
    op.create_index('IX_Exceptions_App_Del_Cre', 'Exceptions', ['ApplicationName', 'DeletionDate', 'CreationDate'], unique=False)
    op.create_table('Roles',
    sa.Column('RoleId', sa.INTEGER(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('RoleName', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('RoleId', name='PK_Roles'),
    postgresql_ignore_search_path=False
    )
    op.create_table('UserRoles',
    sa.Column('UserRoleId', sa.BIGINT(), sa.Identity(always=False, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('UserId', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('RoleId', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['RoleId'], ['Roles.RoleId'], name='FK_UserRoles_RoleId'),
    sa.ForeignKeyConstraint(['UserId'], ['Users.UserId'], name='FK_UserRoles_UserId'),
    sa.PrimaryKeyConstraint('UserRoleId', name='PK_UserRoles')
    )
    op.create_index('UQ_UserRoles_UserId_RoleId', 'UserRoles', ['UserId', 'RoleId'], unique=True)
    op.create_index('IX_UserRoles_RoleId_UserId', 'UserRoles', ['RoleId', 'UserId'], unique=False)
    op.create_table('test_outgate',
    sa.Column('challanid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('slipno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('slipid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('vehicleno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('driver', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('driverid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('loading', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('destination', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('challanno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('gross', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('tare', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('net', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('passdate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('passgate', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('sliptime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('challantime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('printtime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('material', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('weighbridge', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('vehicleid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('locationid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('username', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('transporterid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('transporter', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('challannet', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('grosswbid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('grosswb', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('tarewbid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('tarewb', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('passusername', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('wbdatetime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)
    )
    op.create_table('company',
    sa.Column('cid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('cname', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('address1', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('address2', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('phone', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('cid', name='company_pkey')
    )
    op.create_table('oldvehiclelist',
    sa.Column('vehicleid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('vehicleno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('compliant', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('ownerid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('ownername', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('ownermobile', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('rcno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('tempno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('chasisno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('fitnessexpiry', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('insuranceexpiry', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('permitexpiry', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('pollutionexpiry', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('permittype', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('status', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('statuschangedate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('createdate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('ownerpan', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('rfno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('rfid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('permit', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('insurance', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('pollution', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('fitness', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('isactive', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('roadtax', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('roadtaxexpiry', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('rcdate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('wheeler', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('vowner', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('vcontact', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('vaddress', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('vownership', sa.BOOLEAN(), autoincrement=False, nullable=True)
    )
    op.create_table('weighbridge',
    sa.Column('wbid', sa.INTEGER(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('wbname', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('locationid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('location', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('capacity', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('wbid', name='weighbridge_pkey')
    )
    op.create_table('owners',
    sa.Column('ownerid', sa.INTEGER(), sa.Identity(always=True, start=2001, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('ownername', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('address1', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('address2', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('pan', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('aadhar', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('mobile', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('gst', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('startdate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('enddate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('dlno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('isactive', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True),
    sa.Column('status', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('statuschangedate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('stateid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('state', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('pincode', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('bankname', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('accountno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('ifsc', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('transportercode', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('ownerid', name='owners_pkey')
    )
    op.create_table('fuelgate',
    sa.Column('fuelid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('vehicleno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('slipno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('challanno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('quantity', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('fueltime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('vehicleid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('fuelslipno', sa.TEXT(), sa.Computed("lpad((fuelid)::text, 8, '0'::text)", persisted=True), autoincrement=False, nullable=True),
    sa.Column('username', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('slipid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('transporter', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('transporterid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('location', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('locationid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('wheeler', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('driver', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('driverid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('fuelbyrule', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('fuelid', name='fuelgate_pkey')
    )
    op.create_table('fuelmaster',
    sa.Column('fuelid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('wheels', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('fuelpermt', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('effectivefrom', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)
    )
    op.create_table('Languages',
    sa.Column('Id', sa.INTEGER(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('LanguageId', sa.VARCHAR(length=10), autoincrement=False, nullable=False),
    sa.Column('LanguageName', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('Id', name='PK_Languages')
    )
    op.create_table('test_ingate',
    sa.Column('slipid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('sliptime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('vehicleno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('destination', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('loading', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('dlno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('transporter', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('gate', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('currentlogin', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('driver', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('controlno', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('driverid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('tare', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('rfid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('rfno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('locationid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('transporterid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('vehicleid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('validslip', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('slipno', sa.TEXT(), sa.Computed("lpad((slipid)::text, 8, '0'::text)", persisted=True), autoincrement=False, nullable=True),
    sa.Column('quantity', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('fueltime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('fueloperator', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('wheeler', sa.INTEGER(), autoincrement=False, nullable=True)
    )
    op.create_table('assets',
    sa.Column('assetid', sa.INTEGER(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('assetname', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('category', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('make', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('model', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('serialno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('location', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('installationdate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('assetcode', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('status', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('statuschangedate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('categoryid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('locationid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('assetid', name='assets_pkey')
    )
    op.create_table('oldowners',
    sa.Column('ownerid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('ownername', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('address1', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('address2', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('pan', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('aadhar', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('mobile', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('gst', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('startdate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('enddate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('dlno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('isactive', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('status', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('statuschangedate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('stateid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('state', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('pincode', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('bankname', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('accountno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('ifsc', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('transportercode', sa.TEXT(), autoincrement=False, nullable=True)
    )
    op.create_table('outgate',
    sa.Column('challanid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('slipno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('slipid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('vehicleno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('driver', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('driverid', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('loading', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('destination', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('challanno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('gross', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('tare', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('net', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('passdate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('passgate', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('sliptime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('challantime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('printtime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('material', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('weighbridge', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('vehicleid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('locationid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('username', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('transporterid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('transporter', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('challannet', sa.NUMERIC(precision=18, scale=3), autoincrement=False, nullable=True),
    sa.Column('grosswbid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('grosswb', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('tarewbid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('tarewb', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('passusername', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('wbdatetime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('challanid', name='outgate_pkey'),
    sa.UniqueConstraint('challanno', name='uq_out_challanno'),
    sa.UniqueConstraint('slipno', name='uq_out_slipno')
    )
    op.create_table('RolePermissions',
    sa.Column('RolePermissionId', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('RoleId', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('PermissionKey', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['RoleId'], ['Roles.RoleId'], name='FK_RolePermissions_RoleId'),
    sa.PrimaryKeyConstraint('RolePermissionId', name='PK_RolePermissions')
    )
    op.create_index('UQ_RolePerm_RoleId_PermKey', 'RolePermissions', ['RoleId', 'PermissionKey'], unique=True)
    op.create_table('category',
    sa.Column('categoryid', sa.INTEGER(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=2147483647, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('categoryname', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('parentid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('categoryid', name='category_pkey')
    )
    op.create_table('rfidtag',
    sa.Column('rfid', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('rfno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('isactive', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('issuedate', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('vehicleno', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('vehicleid', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('rfid', name='rfidtag_pkey')
    )
    op.create_table('varpassdate',
    sa.Column('passdate', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)
    )
    op.drop_table('weightbridge')
    op.drop_table('owner')
    op.drop_table('blacklist_tokens')
    op.drop_table('Rfidtag')
    op.drop_table('Outgate')
    op.drop_table('Fuelgate')
    op.drop_table('Category')
    op.drop_table('Assets')
    # ### end Alembic commands ###
