diff --git a/packages/neuron-wallet/src/database/address/entities/address.ts b/packages/neuron-wallet/src/database/address/entities/address.ts index 1cdd995d60..a6391d98ce 100644 --- a/packages/neuron-wallet/src/database/address/entities/address.ts +++ b/packages/neuron-wallet/src/database/address/entities/address.ts @@ -73,6 +73,9 @@ export default class Address extends BaseEntity { @Column() pendingBalance: string = '0' + @Column() + totalBalance: string = '0' + public balance = (): string => { return (BigInt(this.liveBalance) + BigInt(this.sentBalance)).toString() } diff --git a/packages/neuron-wallet/src/database/address/migrations/1562126909151-extendBalance.ts b/packages/neuron-wallet/src/database/address/migrations/1562126909151-extendBalance.ts index 6b6de96d16..516d5befbc 100644 --- a/packages/neuron-wallet/src/database/address/migrations/1562126909151-extendBalance.ts +++ b/packages/neuron-wallet/src/database/address/migrations/1562126909151-extendBalance.ts @@ -13,8 +13,8 @@ export class extendBalance1562126909151 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.dropColumn('transaction', 'sentBalance') - await queryRunner.dropColumn('transaction', 'pendingBalance') + await queryRunner.dropColumn('address', 'sentBalance') + await queryRunner.dropColumn('address', 'pendingBalance') await queryRunner.changeColumn('address', 'liveBalance', new TableColumn({ name: 'balance', type: 'varchar', diff --git a/packages/neuron-wallet/src/database/address/migrations/1567485550388-AddTotalBalance.ts b/packages/neuron-wallet/src/database/address/migrations/1567485550388-AddTotalBalance.ts new file mode 100644 index 0000000000..03b3e5df9b --- /dev/null +++ b/packages/neuron-wallet/src/database/address/migrations/1567485550388-AddTotalBalance.ts @@ -0,0 +1,17 @@ +import {MigrationInterface, QueryRunner, TableColumn} from "typeorm"; + +export class AddTotalBalance1567485550388 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn('address', new TableColumn({ + name: 'totalBalance', + type: 'varchar', + default: '0', + })) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn('address', 'totalBalance') + } + +} diff --git a/packages/neuron-wallet/src/database/address/ormconfig.ts b/packages/neuron-wallet/src/database/address/ormconfig.ts index 7e4731830e..63a6ee6765 100644 --- a/packages/neuron-wallet/src/database/address/ormconfig.ts +++ b/packages/neuron-wallet/src/database/address/ormconfig.ts @@ -8,6 +8,7 @@ import Address from './entities/address' import { AddAddress1561461669542 } from './migrations/1561461669542-AddAddress' import { extendBalance1562126909151 } from './migrations/1562126909151-extendBalance' +import { AddTotalBalance1567485550388 } from './migrations/1567485550388-AddTotalBalance' const dbPath = path.join(env.fileBasePath, 'address.sqlite') @@ -20,7 +21,7 @@ const connectOptions = (): SqliteConnectionOptions => { type: 'sqlite', database, entities: [Address], - migrations: [AddAddress1561461669542, extendBalance1562126909151], + migrations: [AddAddress1561461669542, extendBalance1562126909151, AddTotalBalance1567485550388], synchronize: false, migrationsRun: true, logging: ['error'],