add balance and balance_date to account

This commit is contained in:
einhornimmond 2023-08-25 15:57:06 +02:00
parent b611da90f4
commit ac5e93c813
2 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,8 @@ import { User } from './User'
import { Community } from './Community'
import { TransactionRecipe } from './TransactionRecipe'
import { ConfirmedTransaction } from './ConfirmedTransaction'
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
import Decimal from 'decimal.js-light'
@Entity('accounts')
export class Account {
@ -41,13 +43,24 @@ export class Account {
name: 'created_at',
type: 'datetime',
default: () => 'CURRENT_TIMESTAMP',
nullable: false,
})
createdAt: Date
@Column({ name: 'confirmed_at', type: 'datetime', nullable: true })
confirmedAt?: Date
@Column({
type: 'decimal',
precision: 40,
scale: 20,
default: 0,
transformer: DecimalTransformer,
})
balance: Decimal
@Column({ name: 'balance_date', type: 'datetime' })
balanceDate: Date
@OneToOne(() => Community, (community) => community.gmwAccount)
gmwCommunity?: Community

View File

@ -35,6 +35,8 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
\`type\` tinyint unsigned NOT NULL,
\`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
\`confirmed_at\` datetime DEFAULT NULL,
\`balance\` decimal(40,20) NOT NULL DEFAULT 0,
\`balance_date\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (\`id\`),
UNIQUE KEY \`pubkey\` (\`pubkey\`),
FOREIGN KEY (\`user_id\`) REFERENCES users(id)