mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
add pending_trtansactions table
This commit is contained in:
parent
04a02d53fc
commit
6dbe7b8c4b
@ -0,0 +1,140 @@
|
||||
/* eslint-disable no-use-before-define */
|
||||
import { Decimal } from 'decimal.js-light'
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm'
|
||||
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||
import { Contribution } from '../Contribution'
|
||||
|
||||
@Entity('pending_transactions')
|
||||
export class PendingTransaction extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@Column({ type: 'int', unsigned: true, unique: true, nullable: true, default: null })
|
||||
previous: number | null
|
||||
|
||||
@Column({ name: 'type_id', unsigned: true, nullable: false })
|
||||
typeId: number
|
||||
|
||||
@Column({
|
||||
name: 'transaction_link_id',
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
nullable: true,
|
||||
default: null,
|
||||
})
|
||||
transactionLinkId?: number | null
|
||||
|
||||
@Column({
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
nullable: false,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
amount: Decimal
|
||||
|
||||
@Column({
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
nullable: false,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
balance: Decimal
|
||||
|
||||
@Column({
|
||||
name: 'balance_date',
|
||||
type: 'datetime',
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
nullable: false,
|
||||
})
|
||||
balanceDate: Date
|
||||
|
||||
@Column({
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
nullable: false,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
decay: Decimal
|
||||
|
||||
@Column({
|
||||
name: 'decay_start',
|
||||
type: 'datetime',
|
||||
nullable: true,
|
||||
default: null,
|
||||
})
|
||||
decayStart: Date | null
|
||||
|
||||
@Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||
memo: string
|
||||
|
||||
@Column({ name: 'creation_date', type: 'datetime', nullable: true, default: null })
|
||||
creationDate: Date | null
|
||||
|
||||
@Column({ name: 'user_id', unsigned: true, nullable: false })
|
||||
userId: number
|
||||
|
||||
@Column({
|
||||
name: 'user_gradido_id',
|
||||
type: 'varchar',
|
||||
length: 36,
|
||||
nullable: false,
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
})
|
||||
userGradidoID: string
|
||||
|
||||
@Column({
|
||||
name: 'user_name',
|
||||
type: 'varchar',
|
||||
length: 512,
|
||||
nullable: true,
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
})
|
||||
userName: string | null
|
||||
|
||||
@Column({
|
||||
name: 'linked_user_id',
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
nullable: true,
|
||||
default: null,
|
||||
})
|
||||
linkedUserId?: number | null
|
||||
|
||||
@Column({
|
||||
name: 'linked_user_gradido_id',
|
||||
type: 'varchar',
|
||||
length: 36,
|
||||
nullable: true,
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
})
|
||||
linkedUserGradidoID: string | null
|
||||
|
||||
@Column({
|
||||
name: 'linked_user_name',
|
||||
type: 'varchar',
|
||||
length: 512,
|
||||
nullable: true,
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
})
|
||||
linkedUserName: string | null
|
||||
|
||||
@Column({
|
||||
name: 'linked_transaction_id',
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
nullable: true,
|
||||
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
|
||||
}
|
||||
1
database/entity/PendingTransaction.ts
Normal file
1
database/entity/PendingTransaction.ts
Normal file
@ -0,0 +1 @@
|
||||
export { Transaction } from './0071-add-pending_transactions-table/PendingTransaction'
|
||||
@ -13,6 +13,7 @@ import { Community } from './Community'
|
||||
import { FederatedCommunity } from './FederatedCommunity'
|
||||
import { UserRole } from './UserRole'
|
||||
import { DltTransaction } from './DltTransaction'
|
||||
import { PendingTransaction } from './0071-add-pending_transactions-table/PendingTransaction'
|
||||
|
||||
export const entities = [
|
||||
Community,
|
||||
@ -25,6 +26,7 @@ export const entities = [
|
||||
LoginElopageBuys,
|
||||
LoginEmailOptIn,
|
||||
Migration,
|
||||
PendingTransaction,
|
||||
Transaction,
|
||||
TransactionLink,
|
||||
User,
|
||||
|
||||
34
database/migrations/0071-add-pending_transactions-table.ts
Normal file
34
database/migrations/0071-add-pending_transactions-table.ts
Normal file
@ -0,0 +1,34 @@
|
||||
/* MIGRATION TO add new pending_transactions table */
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(`
|
||||
CREATE TABLE pending_transactions (
|
||||
id int unsigned NOT NULL AUTO_INCREMENT,
|
||||
previous int(10) unsigned DEFAULT NULL NULL,
|
||||
type_id int(10) DEFAULT NULL NULL,
|
||||
transaction_link_id int(10) unsigned DEFAULT NULL NULL,
|
||||
amount decimal(40,20) DEFAULT NULL NULL,
|
||||
balance decimal(40,20) DEFAULT NULL NULL,
|
||||
balance_date datetime(3) DEFAULT current_timestamp(3) NOT NULL,
|
||||
decay decimal(40,20) DEFAULT NULL NULL,
|
||||
decay_start datetime(3) DEFAULT NULL NULL,
|
||||
memo varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
creation_date datetime(3) DEFAULT NULL NULL,
|
||||
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,
|
||||
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_transaction_id int(10) DEFAULT NULL NULL,
|
||||
state int(10) DEFAULT NULL NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`)
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(`DROP TABLE pending_transactions;`)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user