mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
contribution entity
This commit is contained in:
parent
e6d9420d8e
commit
617ea9a2b0
45
database/entity/0037-contributions_table/Contribution.ts
Normal file
45
database/entity/0037-contributions_table/Contribution.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import Decimal from 'decimal.js-light'
|
||||
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
|
||||
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||
|
||||
@Entity('contributions')
|
||||
export class Contribution extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@Column({ unsigned: true, nullable: false, name: 'user_id' })
|
||||
userId: number
|
||||
|
||||
@Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP', name: 'created_at' })
|
||||
createdAt: Date
|
||||
|
||||
@Column({ type: 'datetime', nullable: false, name: 'contribution_date' })
|
||||
contributionDate: Date
|
||||
|
||||
@Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||
memo: string
|
||||
|
||||
@Column({
|
||||
type: 'decimal',
|
||||
precision: 40,
|
||||
scale: 20,
|
||||
nullable: false,
|
||||
transformer: DecimalTransformer,
|
||||
})
|
||||
amount: Decimal
|
||||
|
||||
@Column({ unsigned: true, nullable: true, name: 'moderator_id' })
|
||||
moderatorId: number
|
||||
|
||||
@Column({ unsigned: true, nullable: true, name: 'contribution_link_id' })
|
||||
contributionLinkId: number
|
||||
|
||||
@Column({ unsigned: true, nullable: true, name: 'confirmed_by' })
|
||||
confirmedBy: number
|
||||
|
||||
@Column({ nullable: true, name: 'confirmed_at' })
|
||||
confirmedAt: Date
|
||||
|
||||
@Column({ nullable: true, name: 'deleted_at' })
|
||||
deletedAt: Date
|
||||
}
|
||||
1
database/entity/Contribution.ts
Normal file
1
database/entity/Contribution.ts
Normal file
@ -0,0 +1 @@
|
||||
export { Contribution } from './0037-contributions_table/Contribution'
|
||||
@ -5,10 +5,10 @@ import { Transaction } from './Transaction'
|
||||
import { TransactionLink } from './TransactionLink'
|
||||
import { User } from './User'
|
||||
import { UserSetting } from './UserSetting'
|
||||
import { AdminPendingCreation } from './AdminPendingCreation'
|
||||
import { Contribution } from './Contribution'
|
||||
|
||||
export const entities = [
|
||||
AdminPendingCreation,
|
||||
Contribution,
|
||||
LoginElopageBuys,
|
||||
LoginEmailOptIn,
|
||||
Migration,
|
||||
|
||||
@ -9,9 +9,9 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `userId` `user_id` int(10);')
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `created` `contribution_date` datetime;')
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `created` `created_at` datetime;')
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `date` `created_at` datetime;')
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `date` `contribution_date` datetime;')
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `moderator` `moderator_id` int(10);')
|
||||
|
||||
@ -43,9 +43,9 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `moderator_id` `moderator` int(10);')
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `created_at` `date` datetime;')
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `created_at` `created` datetime;')
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `contribution_date` `created` datetime;')
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `contribution_date` `date` datetime;')
|
||||
|
||||
await queryFn('ALTER TABLE `contributions` CHANGE COLUMN `user_id` `userId` int(10);')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user