fix: change the role refrence in database

This commit is contained in:
mahyargdz
2025-01-19 11:55:52 +03:30
parent 58c9bfa912
commit f88ccec546
10 changed files with 119 additions and 14 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
import { BaseEntity, Column, Entity } from "typeorm";
import { Column, Entity } from "typeorm";
import { BaseEntity } from "../../../common/entities/base.entity";
import { RoleEnum } from "../enums/role.enum";
@Entity()
+3 -2
View File
@@ -1,4 +1,4 @@
import { Column, Entity, OneToOne } from "typeorm";
import { Column, Entity, JoinColumn, OneToOne } from "typeorm";
import { Role } from "./role.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
@@ -26,6 +26,7 @@ export class User extends BaseEntity {
@Column({ type: "varchar", length: 100 })
nationalCode: string;
@OneToOne(() => Role, { eager: true, cascade: true, onDelete: "SET NULL" })
@JoinColumn()
@OneToOne(() => Role, { eager: true, cascade: true, onDelete: "RESTRICT", nullable: false })
role: Role;
}