mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into 2144-feature-usecase-concept-setting-alias-in-user-profile
This commit is contained in:
commit
952bd709c5
@ -10,7 +10,7 @@ Decimal.set({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0046-adapt_users_table_for_gradidoid',
|
DB_VERSION: '0047-messages_tables',
|
||||||
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
||||||
LOG4JS_CONFIG: 'log4js-config.json',
|
LOG4JS_CONFIG: 'log4js-config.json',
|
||||||
// default log level on production should be info
|
// default log level on production should be info
|
||||||
|
|||||||
11
backend/src/graphql/enum/MessageType.ts
Normal file
11
backend/src/graphql/enum/MessageType.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { registerEnumType } from 'type-graphql'
|
||||||
|
|
||||||
|
export enum ContributionMessageType {
|
||||||
|
HISTORY = 'HISTORY',
|
||||||
|
DIALOG = 'DIALOG',
|
||||||
|
}
|
||||||
|
|
||||||
|
registerEnumType(ContributionMessageType, {
|
||||||
|
name: 'ContributionMessageType',
|
||||||
|
description: 'Name of the Type of the ContributionMessage',
|
||||||
|
})
|
||||||
89
database/entity/0047-messages_tables/Contribution.ts
Normal file
89
database/entity/0047-messages_tables/Contribution.ts
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import Decimal from 'decimal.js-light'
|
||||||
|
import {
|
||||||
|
BaseEntity,
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
DeleteDateColumn,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
} from 'typeorm'
|
||||||
|
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||||
|
import { User } from '../User'
|
||||||
|
import { ContributionMessage } from '../ContributionMessage'
|
||||||
|
|
||||||
|
@Entity('contributions')
|
||||||
|
export class Contribution extends BaseEntity {
|
||||||
|
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||||
|
id: number
|
||||||
|
|
||||||
|
@Column({ unsigned: true, nullable: false, name: 'user_id' })
|
||||||
|
userId: number
|
||||||
|
|
||||||
|
@ManyToOne(() => User, (user) => user.contributions)
|
||||||
|
@JoinColumn({ name: 'user_id' })
|
||||||
|
user: User
|
||||||
|
|
||||||
|
@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({ unsigned: true, nullable: true, name: 'denied_by' })
|
||||||
|
deniedBy: number
|
||||||
|
|
||||||
|
@Column({ nullable: true, name: 'denied_at' })
|
||||||
|
deniedAt: Date
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'contribution_type',
|
||||||
|
length: 12,
|
||||||
|
nullable: false,
|
||||||
|
collation: 'utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
contributionType: string
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'contribution_status',
|
||||||
|
length: 12,
|
||||||
|
nullable: false,
|
||||||
|
collation: 'utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
contributionStatus: string
|
||||||
|
|
||||||
|
@Column({ unsigned: true, nullable: true, name: 'transaction_id' })
|
||||||
|
transactionId: number
|
||||||
|
|
||||||
|
@DeleteDateColumn({ name: 'deleted_at' })
|
||||||
|
deletedAt: Date | null
|
||||||
|
|
||||||
|
@OneToMany(() => ContributionMessage, (message) => message.contribution)
|
||||||
|
@JoinColumn({ name: 'contribution_id' })
|
||||||
|
messages?: ContributionMessage[]
|
||||||
|
}
|
||||||
46
database/entity/0047-messages_tables/ContributionMessage.ts
Normal file
46
database/entity/0047-messages_tables/ContributionMessage.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import {
|
||||||
|
BaseEntity,
|
||||||
|
Column,
|
||||||
|
DeleteDateColumn,
|
||||||
|
Entity,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from 'typeorm'
|
||||||
|
import { Contribution } from '../Contribution'
|
||||||
|
|
||||||
|
@Entity('contribution_messages', {
|
||||||
|
engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
export class ContributionMessage extends BaseEntity {
|
||||||
|
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||||
|
id: number
|
||||||
|
|
||||||
|
@Column({ name: 'contribution_id', unsigned: true, nullable: false })
|
||||||
|
contributionId: number
|
||||||
|
|
||||||
|
@ManyToOne(() => Contribution, (contribution) => contribution.messages)
|
||||||
|
@JoinColumn({ name: 'contribution_id' })
|
||||||
|
contribution: Contribution
|
||||||
|
|
||||||
|
@Column({ name: 'user_id', unsigned: true, nullable: false })
|
||||||
|
userId: number
|
||||||
|
|
||||||
|
@Column({ length: 2000, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||||
|
message: string
|
||||||
|
|
||||||
|
@Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP', name: 'created_at' })
|
||||||
|
createdAt: Date
|
||||||
|
|
||||||
|
@Column({ type: 'datetime', default: null, nullable: true, name: 'updated_at' })
|
||||||
|
updatedAt: Date
|
||||||
|
|
||||||
|
@DeleteDateColumn({ name: 'deleted_at' })
|
||||||
|
deletedAt: Date | null
|
||||||
|
|
||||||
|
@Column({ name: 'deleted_by', default: null, unsigned: true, nullable: true })
|
||||||
|
deletedBy: number
|
||||||
|
|
||||||
|
@Column({ length: 12, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||||
|
type: string
|
||||||
|
}
|
||||||
@ -1 +1 @@
|
|||||||
export { Contribution } from './0045-add_denied_type_and_status_to_contributions/Contribution'
|
export { Contribution } from './0047-messages_tables/Contribution'
|
||||||
|
|||||||
1
database/entity/ContributionMessage.ts
Normal file
1
database/entity/ContributionMessage.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { ContributionMessage } from './0047-messages_tables/ContributionMessage'
|
||||||
@ -7,6 +7,7 @@ import { TransactionLink } from './TransactionLink'
|
|||||||
import { User } from './User'
|
import { User } from './User'
|
||||||
import { Contribution } from './Contribution'
|
import { Contribution } from './Contribution'
|
||||||
import { EventProtocol } from './EventProtocol'
|
import { EventProtocol } from './EventProtocol'
|
||||||
|
import { ContributionMessage } from './ContributionMessage'
|
||||||
|
|
||||||
export const entities = [
|
export const entities = [
|
||||||
Contribution,
|
Contribution,
|
||||||
@ -18,4 +19,5 @@ export const entities = [
|
|||||||
TransactionLink,
|
TransactionLink,
|
||||||
User,
|
User,
|
||||||
EventProtocol,
|
EventProtocol,
|
||||||
|
ContributionMessage,
|
||||||
]
|
]
|
||||||
|
|||||||
30
database/migrations/0047-messages_tables.ts
Normal file
30
database/migrations/0047-messages_tables.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* MIGRATION TO CREATE THE MESSAGES TABLES
|
||||||
|
*
|
||||||
|
* This migration creates the `messages` tables in the `community_server` database (`gradido_community`).
|
||||||
|
* This is done to keep all data in the same place and is to be understood in conjunction with the next migration
|
||||||
|
* `0046-messages_tables` which will fill the tables with the existing data
|
||||||
|
*/
|
||||||
|
/* 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 IF NOT EXISTS \`contribution_messages\` (
|
||||||
|
\`id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
\`contribution_id\` int(10) unsigned NOT NULL,
|
||||||
|
\`user_id\` int(10) unsigned NOT NULL,
|
||||||
|
\`message\` varchar(2000) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
\`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
\`updated_at\` datetime DEFAULT NULL,
|
||||||
|
\`deleted_at\` datetime DEFAULT NULL,
|
||||||
|
\`deleted_by\` int(10) unsigned DEFAULT NULL,
|
||||||
|
\`type\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT "DIALOG",
|
||||||
|
PRIMARY KEY (\`id\`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn(`DROP TABLE IF EXISTS \`contribution_messages\`;`)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user