generated from bastian/boilerplate
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
Index,
|
|
PrimaryGeneratedColumn,
|
|
Unique,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
|
|
export enum UserRoleAssignmentSource {
|
|
Manual = 'MANUAL',
|
|
Oidc = 'OIDC',
|
|
System = 'SYSTEM',
|
|
}
|
|
|
|
@Entity('user_role_assignments')
|
|
@Unique('uq_user_role_assignments_source', ['userId', 'roleId', 'source'])
|
|
@Index('idx_user_role_assignments_user', ['userId'])
|
|
export class UserRoleAssignmentEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'user_id', type: 'char', length: 36 })
|
|
userId!: string;
|
|
|
|
@Column({ name: 'role_id', type: 'char', length: 36 })
|
|
roleId!: string;
|
|
|
|
@Column({ type: 'varchar', length: 20 })
|
|
source!: UserRoleAssignmentSource;
|
|
|
|
@Column({
|
|
name: 'last_synchronized_at',
|
|
type: 'datetime',
|
|
precision: 3,
|
|
nullable: true,
|
|
})
|
|
lastSynchronizedAt!: Date | null;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'datetime', precision: 3 })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'datetime', precision: 3 })
|
|
updatedAt!: Date;
|
|
}
|