mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-05 17:36:09 +00:00
rework pending_transactions table and entity
This commit is contained in:
parent
7e13bf8db8
commit
23b333551f
14
backend/src/graphql/enum/PendingTransactionState.ts
Normal file
14
backend/src/graphql/enum/PendingTransactionState.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { registerEnumType } from 'type-graphql'
|
||||
|
||||
export enum PendingTransactionState {
|
||||
NEW = 1,
|
||||
WAIT_ON_PENDING = 2,
|
||||
PENDING = 3,
|
||||
WAIT_ON_CONFIRM = 4,
|
||||
CONFIRMED = 5,
|
||||
}
|
||||
|
||||
registerEnumType(PendingTransactionState, {
|
||||
name: 'PendingTransactionState', // this one is mandatory
|
||||
description: 'State of the PendingTransaction', // this one is optional
|
||||
})
|
||||
@ -1,8 +1,7 @@
|
||||
/* eslint-disable no-use-before-define */
|
||||
import { Decimal } from 'decimal.js-light'
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm'
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||
import { Contribution } from '../Contribution'
|
||||
|
||||
@Entity('pending_transactions')
|
||||
export class PendingTransaction extends BaseEntity {
|
||||
@ -48,7 +47,7 @@ export class PendingTransaction extends BaseEntity {
|
||||
@Column({
|
||||
name: 'balance_date',
|
||||
type: 'datetime',
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
default: () => 'CURRENT_TIMESTAMP(3)',
|
||||
nullable: false,
|
||||
})
|
||||
balanceDate: Date
|
||||
@ -97,6 +96,15 @@ export class PendingTransaction extends BaseEntity {
|
||||
})
|
||||
userName: string | null
|
||||
|
||||
@Column({
|
||||
name: 'user_community_uuid',
|
||||
type: 'varchar',
|
||||
length: 36,
|
||||
nullable: false,
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
})
|
||||
userCommunityUuid: string
|
||||
|
||||
@Column({
|
||||
name: 'linked_user_id',
|
||||
type: 'int',
|
||||
@ -124,6 +132,15 @@ export class PendingTransaction extends BaseEntity {
|
||||
})
|
||||
linkedUserName: string | null
|
||||
|
||||
@Column({
|
||||
name: 'linked_user_community_uuid',
|
||||
type: 'varchar',
|
||||
length: 36,
|
||||
nullable: false,
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
})
|
||||
linkedUserCommunityUuid: string
|
||||
|
||||
@Column({
|
||||
name: 'linked_transaction_id',
|
||||
type: 'int',
|
||||
@ -132,12 +149,4 @@ export class PendingTransaction extends BaseEntity {
|
||||
default: null,
|
||||
})
|
||||
linkedTransactionId?: number | null
|
||||
|
||||
@OneToOne(() => Contribution, (contribution) => contribution.transaction)
|
||||
@JoinColumn({ name: 'id', referencedColumnName: 'transactionId' })
|
||||
contribution?: Contribution | null
|
||||
|
||||
@OneToOne(() => PendingTransaction)
|
||||
@JoinColumn({ name: 'previous' })
|
||||
previousPendingTransaction?: PendingTransaction | null
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
await queryFn(`
|
||||
CREATE TABLE pending_transactions (
|
||||
id int unsigned NOT NULL AUTO_INCREMENT,
|
||||
state int(10) NOT NULL,
|
||||
previous int(10) unsigned DEFAULT NULL NULL,
|
||||
type_id int(10) DEFAULT NULL NULL,
|
||||
transaction_link_id int(10) unsigned DEFAULT NULL NULL,
|
||||
@ -20,11 +21,12 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
user_id int(10) unsigned NOT NULL,
|
||||
user_gradido_id char(36) NOT NULL,
|
||||
user_name varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL NULL,
|
||||
user_community_uuid char(36) NOT NULL,
|
||||
linked_user_id int(10) unsigned DEFAULT NULL NULL,
|
||||
linked_user_gradido_id char(36) NOT NULL,
|
||||
linked_user_name varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL NULL,
|
||||
linked_user_community_uuid char(36) NOT NULL,
|
||||
linked_transaction_id int(10) DEFAULT NULL NULL,
|
||||
state int(10) DEFAULT NULL NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user