feat: add Class, ClassStudent, ClassTeacher entities
This commit is contained in:
47
apps/server/src/entities/class-student.entity.ts
Normal file
47
apps/server/src/entities/class-student.entity.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
Unique,
|
||||
} from 'typeorm';
|
||||
import { Class } from './class.entity';
|
||||
import { Student } from './student.entity';
|
||||
|
||||
@Entity('class_student')
|
||||
@Unique(['classId', 'studentId'])
|
||||
export class ClassStudent {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ name: 'class_id', type: 'integer' })
|
||||
classId: number;
|
||||
|
||||
@ManyToOne(() => Class, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'class_id' })
|
||||
class: Class;
|
||||
|
||||
@Column({ name: 'student_id', type: 'integer' })
|
||||
studentId: number;
|
||||
|
||||
@ManyToOne(() => Student)
|
||||
@JoinColumn({ name: 'student_id' })
|
||||
student: Student;
|
||||
|
||||
@Column({ name: 'enrollment_id', type: 'integer', nullable: true })
|
||||
enrollmentId: number;
|
||||
|
||||
@Column({ name: 'join_date', type: 'date', nullable: true })
|
||||
joinDate: string;
|
||||
|
||||
@Column({ name: 'leave_date', type: 'date', nullable: true })
|
||||
leaveDate: string;
|
||||
|
||||
@Column({ name: 'status', length: 10, default: 'active' })
|
||||
status: string;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user