mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change Message to ContributionMessage, change 0046 to 0047.
This commit is contained in:
parent
6bb2ae34b1
commit
e4ec7a1d59
@ -10,7 +10,7 @@ Decimal.set({
|
||||
})
|
||||
|
||||
const constants = {
|
||||
DB_VERSION: '0046-messages_tables',
|
||||
DB_VERSION: '0047-messages_tables',
|
||||
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
||||
LOG4JS_CONFIG: 'log4js-config.json',
|
||||
// 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',
|
||||
})
|
||||
@ -11,7 +11,7 @@ import {
|
||||
} from 'typeorm'
|
||||
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||
import { User } from '../User'
|
||||
import { Message } from '../Message'
|
||||
import { ContributionMessage } from '../ContributionMessage'
|
||||
|
||||
@Entity('contributions')
|
||||
export class Contribution extends BaseEntity {
|
||||
@ -83,7 +83,7 @@ export class Contribution extends BaseEntity {
|
||||
@DeleteDateColumn({ name: 'deleted_at' })
|
||||
deletedAt: Date | null
|
||||
|
||||
@OneToMany(() => Message, (message) => message.contribution)
|
||||
@OneToMany(() => ContributionMessage, (message) => message.contribution)
|
||||
@JoinColumn({ name: 'contribution_id' })
|
||||
messages?: Message[]
|
||||
messages?: ContributionMessage[]
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
import { BaseEntity, Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
|
||||
import { Contribution } from '../Contribution'
|
||||
|
||||
@Entity('messages', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||
export class Message extends BaseEntity {
|
||||
@Entity('contribution_messages', {
|
||||
engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci',
|
||||
})
|
||||
export class ContributionMessage extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@ -30,4 +32,7 @@ export class Message extends BaseEntity {
|
||||
|
||||
@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 './0046-messages_tables/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'
|
||||
@ -1 +0,0 @@
|
||||
export { Message } from './0046-messages_tables/Message'
|
||||
@ -7,7 +7,7 @@ import { TransactionLink } from './TransactionLink'
|
||||
import { User } from './User'
|
||||
import { Contribution } from './Contribution'
|
||||
import { EventProtocol } from './EventProtocol'
|
||||
import { Message } from './Message'
|
||||
import { ContributionMessage } from './ContributionMessage'
|
||||
|
||||
export const entities = [
|
||||
Contribution,
|
||||
@ -19,5 +19,5 @@ export const entities = [
|
||||
TransactionLink,
|
||||
User,
|
||||
EventProtocol,
|
||||
Message,
|
||||
ContributionMessage,
|
||||
]
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(`
|
||||
CREATE TABLE IF NOT EXISTS \`messages\` (
|
||||
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,
|
||||
@ -19,11 +19,12 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
\`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 \`messages\`;`)
|
||||
await queryFn(`DROP TABLE IF EXISTS \`contribution_messages\`;`)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user