adapt User and UserContact entity

This commit is contained in:
Claus-Peter Hübner 2022-07-21 23:16:19 +02:00
parent cca6226b55
commit cb4ee4590a
3 changed files with 18 additions and 6 deletions

View File

@ -1,4 +1,13 @@
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm'
import {
BaseEntity,
Entity,
PrimaryGeneratedColumn,
Column,
DeleteDateColumn,
OneToMany,
JoinColumn,
} from 'typeorm'
import { Contribution } from '../Contribution'
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
export class User extends BaseEntity {
@ -9,7 +18,6 @@ export class User extends BaseEntity {
name: 'gradido_id',
length: 36,
nullable: false,
default: null,
collation: 'utf8mb4_unicode_ci',
})
gradidoID: string
@ -94,4 +102,8 @@ export class User extends BaseEntity {
default: null,
})
passphrase: string
@OneToMany(() => Contribution, (contribution) => contribution.user)
@JoinColumn({ name: 'user_id' })
contributions?: Contribution[]
}

View File

@ -29,12 +29,12 @@ export class UserContact extends BaseEntity {
@Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' })
phone: string
@Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false })
@Column({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP', nullable: false })
createdAt: Date
@DeleteDateColumn()
@DeleteDateColumn({ name: 'updated_at', nullable: true })
updatedAt: Date | null
@DeleteDateColumn()
@DeleteDateColumn({ name: 'deleted_at', nullable: true })
deletedAt: Date | null
}

View File

@ -1 +1 @@
export { User } from './0039-contributions_table/User'
export { User } from './0044-adapt_users_table_for_gradidoid/User'