Exemple #1
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "lrf_data",
        sa.Column("postal_code",
                  sa.BIGINT(),
                  autoincrement=False,
                  nullable=True),
        sa.Column(
            "http://webprotege.stanford.edu/R9vkBr0EApzeMGfa0rJGo9G",
            mssql.BIT(),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "http://webprotege.stanford.edu/RJAL6Zu9F3EHB35HCs3cYD",
            mssql.BIT(),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "http://webprotege.stanford.edu/RcIHdxpjQwjr8EG8yMhEYV",
            mssql.BIT(),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "http://webprotege.stanford.edu/RDudF9SBo28CKqKpRN9poYL",
            mssql.BIT(),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "http://webprotege.stanford.edu/RLc1ySxaRs4HWkW4m5w2Me",
            mssql.BIT(),
            autoincrement=False,
            nullable=True,
        ),
    )
    op.create_index("ix_lrf_data_postal_code",
                    "lrf_data", ["postal_code"],
                    unique=False)
    op.drop_table("signup")
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'post',
        sa.Column('post_id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('author_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('post_title',
                  sa.VARCHAR(length=200,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('post_subtitle',
                  sa.VARCHAR(length=300,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('post_content',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('post_date',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('post_was_edited',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('post_archived',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=True),
        sa.PrimaryKeyConstraint('post_id', name='PK__post__3ED7876691F33FCB'))
    op.drop_table('ARTICLE')
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'User',
        sa.Column('is_admin', mssql.BIT(), autoincrement=False, nullable=True))
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'ViTri', type_='foreignkey')
    op.create_foreign_key('FK__ViTri__user_id__6A30C649', 'ViTri', 'User',
                          ['user_id'], ['id'])
    op.drop_constraint(None, 'SoDienThoai', type_='foreignkey')
    op.create_foreign_key('FK__SoDienTho__user___66603565', 'SoDienThoai',
                          'User', ['user_id'], ['id'])
    op.drop_constraint(None, 'ChucDanhNghiepVuUser', type_='foreignkey')
    op.create_foreign_key('FK__ChucDanhN__user___2A164134',
                          'ChucDanhNghiepVuUser', 'User', ['user_id'], ['id'])
    op.drop_constraint(None, 'ChucDanhCongTacUser', type_='foreignkey')
    op.create_foreign_key('FK__ChucDanhC__user___245D67DE',
                          'ChucDanhCongTacUser', 'User', ['user_id'], ['id'])
    op.create_table(
        'User',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('ho_dem',
                  sa.NVARCHAR(length=30),
                  autoincrement=False,
                  nullable=True),
        sa.Column('ten',
                  sa.NVARCHAR(length=15),
                  autoincrement=False,
                  nullable=True),
        sa.Column('ngay_sinh', sa.DATE(), autoincrement=False, nullable=True),
        sa.Column('nam_gioi',
                  sa.NCHAR(length=1),
                  autoincrement=False,
                  nullable=True),
        sa.Column('nhom_mau',
                  sa.VARCHAR(length=10,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('dan_toc',
                  sa.NVARCHAR(length=20),
                  autoincrement=False,
                  nullable=True),
        sa.Column('que',
                  sa.NVARCHAR(length=100),
                  autoincrement=False,
                  nullable=True),
        sa.Column('dktt',
                  sa.NVARCHAR(length=100),
                  autoincrement=False,
                  nullable=True),
        sa.Column('noi_o',
                  sa.NVARCHAR(length=100),
                  autoincrement=False,
                  nullable=True),
        sa.Column('so_hieu',
                  sa.VARCHAR(length=6,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('ngay_vao_cong_an',
                  sa.DATE(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('nganh_ngoai',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('trinh_do_chinh_tri',
                  sa.NVARCHAR(length=30),
                  autoincrement=False,
                  nullable=True),
        sa.Column('trinh_do_ngoai_ngu',
                  sa.NVARCHAR(length=30),
                  autoincrement=False,
                  nullable=True),
        sa.Column('trinh_do_tin_hoc',
                  sa.NVARCHAR(length=30),
                  autoincrement=False,
                  nullable=True),
        sa.Column('trang_thai_user_id',
                  sa.SMALLINT(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('username',
                  sa.VARCHAR(length=20,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('email',
                  sa.VARCHAR(length=120,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('password_hash',
                  sa.VARCHAR(length=128,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('is_admin', mssql.BIT(), autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['trang_thai_user_id'], ['TrangThaiUser.id'],
                                name='FK__User__trang_thai__656C112C'),
        sa.PrimaryKeyConstraint('id', name='PK__User__3213E83F405FB3BD'))
    op.create_index('ix_User_ten', 'User', ['ten'], unique=False)
    op.drop_index(op.f('ix_nhansu_User_username'),
                  table_name='User',
                  schema='nhansu')
    op.drop_index(op.f('ix_nhansu_User_ten'),
                  table_name='User',
                  schema='nhansu')
    op.drop_index(op.f('ix_nhansu_User_email'),
                  table_name='User',
                  schema='nhansu')
    op.drop_table('User', schema='nhansu')
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('ViTri', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), schema='NhanSu')
    op.drop_constraint(None, 'ViTri', schema='NhanSu', type_='foreignkey')
    op.create_foreign_key('FK__ViTri__user_id__489AC854', 'ViTri', 'User', ['user_id'], ['id'], source_schema='NhanSu', referent_schema='NhanSu')
    op.drop_column('ViTri', 'can_bo_id', schema='NhanSu')
    op.add_column('User', sa.Column('noi_o', sa.NVARCHAR(length=100), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('que', sa.NVARCHAR(length=100), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('nhom_mau', sa.VARCHAR(length=10, collation='SQL_Latin1_General_CP1_CI_AS'), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('gioi_tinh', sa.NCHAR(length=1), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('trinh_do_chinh_tri', sa.NVARCHAR(length=30), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('trinh_do_ngoai_ngu', sa.NVARCHAR(length=30), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('ten', sa.NVARCHAR(length=15), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('ngay_sinh', sa.DATE(), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('dan_toc', sa.NVARCHAR(length=20), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('dktt', sa.NVARCHAR(length=100), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('ho_dem', sa.NVARCHAR(length=30), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('trang_thai_cong_tac_id', sa.SMALLINT(), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('trinh_do_tin_hoc', sa.NVARCHAR(length=30), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('ngay_vao_cong_an', sa.DATE(), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('nganh_ngoai', mssql.BIT(), autoincrement=False, nullable=True), schema='NhanSu')
    op.add_column('User', sa.Column('so_hieu', sa.VARCHAR(length=6, collation='SQL_Latin1_General_CP1_CI_AS'), autoincrement=False, nullable=True), schema='NhanSu')
    op.create_foreign_key('FK__User__trang_thai__2FCF1A8A', 'User', 'TrangThaiCongTac', ['trang_thai_cong_tac_id'], ['id'], source_schema='NhanSu', referent_schema='NhanSu')
    op.create_index('ix_NhanSu_User_ten', 'User', ['ten'], unique=False, schema='NhanSu')
    op.add_column('SoDienThoai', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), schema='NhanSu')
    op.drop_constraint(None, 'SoDienThoai', schema='NhanSu', type_='foreignkey')
    op.create_foreign_key('FK__SoDienTho__user___44CA3770', 'SoDienThoai', 'User', ['user_id'], ['id'], source_schema='NhanSu', referent_schema='NhanSu')
    op.drop_column('SoDienThoai', 'can_bo_id', schema='NhanSu')
    op.create_table('HeSoLuongUser',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False, mssql_identity_start=1, mssql_identity_increment=1),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('he_so', sa.DECIMAL(precision=4, scale=2), autoincrement=False, nullable=True),
    sa.Column('ngay_bat_dau', sa.DATE(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['NhanSu.User.id'], name='FK__HeSoLuong__user___41EDCAC5'),
    sa.PrimaryKeyConstraint('id', name='PK__HeSoLuon__3213E83F3D9EB5CD'),
    schema='NhanSu'
    )
    op.create_table('ChucDanhTuPhapUser',
    sa.Column('id', sa.SMALLINT(), autoincrement=True, nullable=False, mssql_identity_start=1, mssql_identity_increment=1),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('chuc_danh_tu_phap_id', sa.SMALLINT(), autoincrement=False, nullable=True),
    sa.Column('ngay_bat_dau', sa.DATE(), autoincrement=False, nullable=True),
    sa.Column('ngay_ket_thuc', sa.DATE(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['chuc_danh_tu_phap_id'], ['NhanSu.ChucDanhTuPhap.id'], name='FK__ChucDanhT__chuc___3E1D39E1'),
    sa.ForeignKeyConstraint(['user_id'], ['NhanSu.User.id'], name='FK__ChucDanhT__user___3F115E1A'),
    sa.PrimaryKeyConstraint('id', name='PK__ChucDanh__3213E83F44920B68'),
    schema='NhanSu'
    )
    op.create_table('ChucDanhNghiepVuUser',
    sa.Column('id', sa.SMALLINT(), autoincrement=True, nullable=False, mssql_identity_start=1, mssql_identity_increment=1),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('chuc_danh_nghiep_vu_id', sa.SMALLINT(), autoincrement=False, nullable=True),
    sa.Column('ngay_bat_dau', sa.DATE(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['chuc_danh_nghiep_vu_id'], ['NhanSu.ChucDanhNghiepVu.id'], name='FK__ChucDanhN__chuc___3A4CA8FD'),
    sa.ForeignKeyConstraint(['user_id'], ['NhanSu.User.id'], name='FK__ChucDanhN__user___3B40CD36'),
    sa.PrimaryKeyConstraint('id', name='PK__ChucDanh__3213E83F66F9C81E'),
    schema='NhanSu'
    )
    op.create_table('CapBacUser',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False, mssql_identity_start=1, mssql_identity_increment=1),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('cap_bac_id', sa.SMALLINT(), autoincrement=False, nullable=True),
    sa.Column('ngay_bat_dau', sa.DATE(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['cap_bac_id'], ['NhanSu.CapBac.id'], name='FK__CapBacUse__cap_b__32AB8735'),
    sa.ForeignKeyConstraint(['user_id'], ['NhanSu.User.id'], name='FK__CapBacUse__user___339FAB6E'),
    sa.PrimaryKeyConstraint('id', name='PK__CapBacUs__3213E83F71EF910A'),
    schema='NhanSu'
    )
    op.create_table('ChucDanhCongTacUser',
    sa.Column('id', sa.SMALLINT(), autoincrement=True, nullable=False, mssql_identity_start=1, mssql_identity_increment=1),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('chuc_danh_cong_tac_id', sa.SMALLINT(), autoincrement=False, nullable=True),
    sa.Column('ngay_bat_dau', sa.DATE(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['chuc_danh_cong_tac_id'], ['NhanSu.ChucDanhCongTac.id'], name='FK__ChucDanhC__chuc___367C1819'),
    sa.ForeignKeyConstraint(['user_id'], ['NhanSu.User.id'], name='FK__ChucDanhC__user___37703C52'),
    sa.PrimaryKeyConstraint('id', name='PK__ChucDanh__3213E83FB6B44B67'),
    schema='NhanSu'
    )
    op.drop_table('HeSoLuongCanBo', schema='NhanSu')
    op.drop_table('ChucDanhTuPhapCanBo', schema='NhanSu')
    op.drop_table('ChucDanhNghiepVuCanBo', schema='NhanSu')
    op.drop_table('ChucDanhCongTacCanBo', schema='NhanSu')
    op.drop_table('CapBacCanBo', schema='NhanSu')
    op.drop_index(op.f('ix_NhanSu_CanBo_ten'), table_name='CanBo', schema='NhanSu')
    op.drop_table('CanBo', schema='NhanSu')
Exemple #6
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'clients',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('name',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('phone',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('address_1',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('address_2',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('city',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('post_code',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('owner_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['owner_id'], ['users.id'],
                                name='FK__clients__owner_i__4E88ABD4'),
        sa.PrimaryKeyConstraint('id', name='PK__clients__3213E83F3C0C35C0'))
    op.create_table(
        'company',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('name',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('contact_person',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('email',
                  sa.VARCHAR(length=50,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('phone',
                  sa.VARCHAR(length=25,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('address_ln_1',
                  sa.VARCHAR(length=100,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('address_ln_2',
                  sa.VARCHAR(length=100,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('city',
                  sa.VARCHAR(length=50,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('postal_code',
                  sa.VARCHAR(length=15,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('owner_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['owner_id'], ['users.id'],
                                name='FK__company__owner_i__4BAC3F29'),
        sa.PrimaryKeyConstraint('id', name='PK__company__3213E83FE11281F0'))
    op.create_table(
        'users',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('username',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('email',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('password_hash',
                  sa.VARCHAR(length=128,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='PK__users__3213E83FE62C9958'))
    op.create_table(
        'invoice_line',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('invoice_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('service_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('product_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('quantity',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('charge', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(['invoice_id'], ['invoice.id'],
                                name='FK__invoice_l__invoi__66603565'),
        sa.ForeignKeyConstraint(['product_id'], ['invoice.id'],
                                name='FK__invoice_l__produ__68487DD7'),
        sa.ForeignKeyConstraint(['service_id'], ['invoice.id'],
                                name='FK__invoice_l__servi__6754599E'),
        sa.PrimaryKeyConstraint('id', name='PK__invoice___3213E83F3144F170'))
    op.create_index('ix_invoice_line_service_id',
                    'invoice_line', ['service_id'],
                    unique=False)
    op.create_index('ix_invoice_line_product_id',
                    'invoice_line', ['product_id'],
                    unique=False)
    op.create_index('ix_invoice_line_invoice_id',
                    'invoice_line', ['invoice_id'],
                    unique=False)
    op.create_table(
        'payment_detail',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('acc_name',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('bank_name',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('sort_code',
                  sa.VARCHAR(length=6,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('acc_number',
                  sa.VARCHAR(length=8,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('owner_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['owner_id'], ['users.id'],
                                name='FK__payment_d__owner__5165187F'),
        sa.PrimaryKeyConstraint('id', name='PK__payment___3213E83FE1985A29'))
    op.create_table(
        'product',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('name',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('description',
                  sa.VARCHAR(length=254,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('price',
                  sa.NUMERIC(precision=12, scale=6),
                  autoincrement=False,
                  nullable=True),
        sa.Column('owner_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['owner_id'], ['users.id'],
                                name='FK__product__owner_i__5441852A'),
        sa.PrimaryKeyConstraint('id', name='PK__product__3213E83FD1F2D2DB'))
    op.create_table(
        'invoice',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('invoice_date',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('company_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('payment_detail_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('owner_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['company_id'], ['company.id'],
                                name='FK__invoice__company__5CD6CB2B'),
        sa.ForeignKeyConstraint(['owner_id'], ['users.id'],
                                name='FK__invoice__owner_i__5EBF139D'),
        sa.ForeignKeyConstraint(['payment_detail_id'], ['payment_detail.id'],
                                name='FK__invoice__payment__5DCAEF64'),
        sa.PrimaryKeyConstraint('id', name='PK__invoice__3213E83F3C9DBD09'))
    op.create_index('ix_invoice_payment_detail_id',
                    'invoice', ['payment_detail_id'],
                    unique=False)
    op.create_index('ix_invoice_owner_id',
                    'invoice', ['owner_id'],
                    unique=False)
    op.create_index('ix_invoice_company_id',
                    'invoice', ['company_id'],
                    unique=False)
    op.create_table(
        'service',
        sa.Column('id',
                  sa.INTEGER(),
                  autoincrement=True,
                  nullable=False,
                  mssql_identity_start=1,
                  mssql_identity_increment=1),
        sa.Column('active_status',
                  mssql.BIT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('created_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('creation_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_by',
                  sa.VARCHAR(collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('update_time',
                  sa.DATETIME(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('name',
                  sa.VARCHAR(length=64,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('description',
                  sa.VARCHAR(length=254,
                             collation='SQL_Latin1_General_CP1_CI_AS'),
                  autoincrement=False,
                  nullable=True),
        sa.Column('charge',
                  sa.FLOAT(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('owner_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['owner_id'], ['users.id'],
                                name='FK__service__owner_i__571DF1D5'),
        sa.PrimaryKeyConstraint('id', name='PK__service__3213E83F5ED8B3B1'))