import { BaseEntity, Column, CreateDateColumn, Entity, JoinColumn, OneToMany, OneToOne, PrimaryColumn, UpdateDateColumn, } from 'typeorm'; import { Customer } from '~/customer/entities'; import { Junior } from '~/junior/entities'; @Entity('guardians') export class Guardian extends BaseEntity { @PrimaryColumn('uuid') id!: string; @Column('uuid', { name: 'customer_id' }) customerId!: string; @OneToOne(() => Customer, (customer) => customer.guardian, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'customer_id' }) customer!: Customer; @OneToMany(() => Junior, (junior) => junior.guardian) juniors!: Junior[]; @CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' }) createdAt!: Date; @UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' }) updatedAt!: Date; }