mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
update name for balances
This commit is contained in:
parent
712e6f61cb
commit
5c11f2e85d
@ -22,9 +22,9 @@ export class AccountFactory {
|
||||
account.derive2Pubkey = parentKeyPair.derive([derivationIndex]).publicKey
|
||||
account.type = type.valueOf()
|
||||
account.createdAt = createdAt
|
||||
account.balanceConfirmedAt = new Decimal(0)
|
||||
account.balanceCreatedAt = new Decimal(0)
|
||||
account.balanceCreatedAtDate = createdAt
|
||||
account.balanceOnConfirmation = new Decimal(0)
|
||||
account.balanceOnCreation = new Decimal(0)
|
||||
account.balanceCreatedAt = createdAt
|
||||
return account
|
||||
}
|
||||
|
||||
|
||||
@ -46,9 +46,9 @@ describe('data/Account test factory and repository', () => {
|
||||
),
|
||||
type: AddressType.COMMUNITY_HUMAN,
|
||||
createdAt: now,
|
||||
balanceCreatedAtDate: now,
|
||||
balanceConfirmedAt: new Decimal(0),
|
||||
balanceCreatedAt: new Decimal(0),
|
||||
balanceCreatedAt: now,
|
||||
balanceOnConfirmation: new Decimal(0),
|
||||
balanceOnCreation: new Decimal(0),
|
||||
})
|
||||
})
|
||||
|
||||
@ -67,9 +67,9 @@ describe('data/Account test factory and repository', () => {
|
||||
),
|
||||
type: AddressType.COMMUNITY_HUMAN,
|
||||
createdAt: now,
|
||||
balanceCreatedAtDate: now,
|
||||
balanceConfirmedAt: new Decimal(0),
|
||||
balanceCreatedAt: new Decimal(0),
|
||||
balanceCreatedAt: now,
|
||||
balanceOnConfirmation: new Decimal(0),
|
||||
balanceOnCreation: new Decimal(0),
|
||||
})
|
||||
})
|
||||
|
||||
@ -83,9 +83,9 @@ describe('data/Account test factory and repository', () => {
|
||||
),
|
||||
type: AddressType.COMMUNITY_GMW,
|
||||
createdAt: now,
|
||||
balanceCreatedAtDate: now,
|
||||
balanceConfirmedAt: new Decimal(0),
|
||||
balanceCreatedAt: new Decimal(0),
|
||||
balanceCreatedAt: now,
|
||||
balanceOnConfirmation: new Decimal(0),
|
||||
balanceOnCreation: new Decimal(0),
|
||||
})
|
||||
})
|
||||
|
||||
@ -99,9 +99,9 @@ describe('data/Account test factory and repository', () => {
|
||||
),
|
||||
type: AddressType.COMMUNITY_AUF,
|
||||
createdAt: now,
|
||||
balanceCreatedAtDate: now,
|
||||
balanceConfirmedAt: new Decimal(0),
|
||||
balanceCreatedAt: new Decimal(0),
|
||||
balanceCreatedAt: now,
|
||||
balanceOnConfirmation: new Decimal(0),
|
||||
balanceOnCreation: new Decimal(0),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -43,39 +43,39 @@ export class Account extends BaseEntity {
|
||||
confirmedAt?: Date
|
||||
|
||||
@Column({
|
||||
name: 'balance_confirmed_at',
|
||||
name: 'balance_on_confirmation',
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
default: 0,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
balanceConfirmedAt: Decimal
|
||||
balanceOnConfirmation: Decimal
|
||||
|
||||
// use timestamp from iota milestone which is only in seconds precision, so no need to use 3 Bytes extra here
|
||||
@Column({
|
||||
name: 'balance_confirmed_at_date',
|
||||
name: 'balance_confirmed_at',
|
||||
type: 'datetime',
|
||||
nullable: true,
|
||||
})
|
||||
balanceConfirmedAtDate: Date
|
||||
balanceConfirmedAt: Date
|
||||
|
||||
@Column({
|
||||
name: 'balance_created_at',
|
||||
name: 'balance_on_creation',
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
default: 0,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
balanceCreatedAt: Decimal
|
||||
balanceOnCreation: Decimal
|
||||
|
||||
@Column({
|
||||
name: 'balance_created_at_date',
|
||||
name: 'balance_created_at',
|
||||
type: 'datetime',
|
||||
precision: 3,
|
||||
})
|
||||
balanceCreatedAtDate: Date
|
||||
balanceCreatedAt: Date
|
||||
|
||||
@OneToMany(() => AccountCommunity, (accountCommunity) => accountCommunity.account)
|
||||
@JoinColumn({ name: 'account_id' })
|
||||
|
||||
@ -73,14 +73,14 @@ export class Transaction extends BaseEntity {
|
||||
|
||||
// account balance for sender based on creation date
|
||||
@Column({
|
||||
name: 'account_balance_created_at',
|
||||
name: 'account_balance_on_creation',
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
nullable: true,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
accountBalanceCreatedAt?: Decimal
|
||||
accountBalanceOnCreation?: Decimal
|
||||
|
||||
@Column({ type: 'tinyint' })
|
||||
type: number
|
||||
@ -105,14 +105,14 @@ export class Transaction extends BaseEntity {
|
||||
|
||||
// account balance for sender based on confirmation date (iota milestone)
|
||||
@Column({
|
||||
name: 'account_balance_confirmed_at',
|
||||
name: 'account_balance_on_confirmation',
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
nullable: true,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
accountBalanceConfirmedAt?: Decimal
|
||||
accountBalanceOnConfirmation?: Decimal
|
||||
|
||||
@Column({ name: 'iota_milestone', type: 'bigint', nullable: true })
|
||||
iotaMilestone?: number
|
||||
|
||||
@ -8,19 +8,19 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
|
||||
await queryFn(`
|
||||
ALTER TABLE \`accounts\`
|
||||
RENAME COLUMN \`balance\` TO \`balance_confirmed_at\`,
|
||||
RENAME COLUMN \`balance_date\` TO \`balance_confirmed_at_date\`
|
||||
RENAME COLUMN \`balance\` TO \`balance_on_confirmation\`,
|
||||
RENAME COLUMN \`balance_date\` TO \`balance_confirmed_at\`
|
||||
;
|
||||
`)
|
||||
|
||||
await queryFn(
|
||||
`ALTER TABLE \`accounts\` ADD COLUMN \`balance_created_at\` decimal(40,20) NOT NULL DEFAULT 0 AFTER \`balance_confirmed_at_date\`;`,
|
||||
`ALTER TABLE \`accounts\` ADD COLUMN \`balance_on_creation\` decimal(40,20) NOT NULL DEFAULT 0 AFTER \`balance_confirmed_at\`;`,
|
||||
)
|
||||
await queryFn(
|
||||
`ALTER TABLE \`accounts\` ADD COLUMN \`balance_created_at_date\` datetime(3) NOT NULL AFTER \`balance_created_at\`;`,
|
||||
`ALTER TABLE \`accounts\` ADD COLUMN \`balance_created_at\` datetime(3) NOT NULL AFTER \`balance_on_creation\`;`,
|
||||
)
|
||||
await queryFn(
|
||||
`ALTER TABLE \`accounts\` MODIFY COLUMN \`balance_confirmed_at_date\` datetime NULL DEFAULT NULL;`,
|
||||
`ALTER TABLE \`accounts\` MODIFY COLUMN \`balance_confirmed_at\` datetime NULL DEFAULT NULL;`,
|
||||
)
|
||||
|
||||
await queryFn(
|
||||
@ -41,7 +41,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
\`community_id\` int unsigned NOT NULL,
|
||||
\`other_community_id\` int unsigned NULL DEFAULT NULL,
|
||||
\`amount\` decimal(40, 20) NULL DEFAULT NULL,
|
||||
\`account_balance_created_at\` decimal(40, 20) NULL DEFAULT 0.00000000000000000000,
|
||||
\`account_balance_on_creation\` decimal(40, 20) NULL DEFAULT 0.00000000000000000000,
|
||||
\`type\` tinyint NOT NULL,
|
||||
\`created_at\` datetime(3) NOT NULL,
|
||||
\`body_bytes\` blob NOT NULL,
|
||||
@ -49,7 +49,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
\`protocol_version\` varchar(255) NOT NULL DEFAULT '1',
|
||||
\`nr\` bigint NULL DEFAULT NULL,
|
||||
\`running_hash\` varbinary(48) NULL DEFAULT NULL,
|
||||
\`account_balance_confirmed_at\` decimal(40, 20) NULL DEFAULT 0.00000000000000000000,
|
||||
\`account_balance_on_confirmation\` decimal(40, 20) NULL DEFAULT 0.00000000000000000000,
|
||||
\`iota_milestone\` bigint NULL DEFAULT NULL,
|
||||
\`confirmed_at\` datetime NULL DEFAULT NULL,
|
||||
PRIMARY KEY (\`id\`),
|
||||
@ -115,13 +115,13 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom
|
||||
)
|
||||
await queryFn(`
|
||||
ALTER TABLE \`accounts\`
|
||||
RENAME COLUMN \`balance_confirmed_at\` TO \`balance\`,
|
||||
RENAME COLUMN \`balance_confirmed_at_date\` TO \`balance_date\`
|
||||
RENAME COLUMN \`balance_on_confirmation\` TO \`balance\`,
|
||||
RENAME COLUMN \`balance_confirmed_at\` TO \`balance_date\`
|
||||
;
|
||||
`)
|
||||
|
||||
await queryFn(`ALTER TABLE \`accounts\` DROP COLUMN \`balance_on_creation\`;`)
|
||||
await queryFn(`ALTER TABLE \`accounts\` DROP COLUMN \`balance_created_at\`;`)
|
||||
await queryFn(`ALTER TABLE \`accounts\` DROP COLUMN \`balance_created_at_date\`;`)
|
||||
await queryFn(`ALTER TABLE \`invalid_transactions\` DROP COLUMN \`error_message\`;`)
|
||||
await queryFn(`ALTER TABLE \`invalid_transactions\` DROP INDEX \`iota_message_id\`;`)
|
||||
await queryFn(`ALTER TABLE \`invalid_transactions\` ADD INDEX(\`iota_message_id\`); `)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user