adding entities for taskmanager

This commit is contained in:
2026-06-29 16:43:17 +03:30
parent 53090153fb
commit e728303d53
18 changed files with 507 additions and 44 deletions
@@ -0,0 +1,42 @@
import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany } from "typeorm";
import { BaseEntity } from "../../../common/entities/base.entity";
import { TMWorkspaceType } from "./workspace-type.entity";
import { TMProject } from "./project.entity";
import { User } from "../../users/entities/user.entity";
@Entity("tm_workspaces")
export class TMWorkspace extends BaseEntity {
@Column({ type: "varchar", length: 100 })
name: string;
@Column({ type: "text", nullable: true })
description: string;
@Column({ type: "varchar", length: 20 })
color: string;
@Column({ type: "boolean", default: true })
isActive: boolean;
// --- Relations ---
@ManyToOne(() => TMWorkspaceType, { nullable: false, eager: true })
@JoinColumn({ name: "workspaceTypeId" })
workspaceType: TMWorkspaceType;
@Column({ type: "uuid" })
workspaceTypeId: string;
@OneToMany(() => TMProject, (project) => project.workspace, {
cascade: ["insert", "update"],
})
projects: TMProject[];
@ManyToMany(() => User, (user) => user.workspaces)
@JoinTable({
name: "tm_workspace_users",
joinColumn: { name: "workspaceId", referencedColumnName: "id" },
inverseJoinColumn: { name: "userId", referencedColumnName: "id" },
})
users: User[];
}