From 81b55b27ab54cb93b61aaec137de054051cd3f76 Mon Sep 17 00:00:00 2001 From: "fazri.is" Date: Thu, 18 Sep 2025 02:44:24 +0700 Subject: [PATCH] update --- src/entity/trx_companies.ts | 7 +++++-- src/entity/trx_company_accounts.ts | 4 ++-- src/entity/trx_registration.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/entity/trx_companies.ts b/src/entity/trx_companies.ts index fca0c42..7104a10 100644 --- a/src/entity/trx_companies.ts +++ b/src/entity/trx_companies.ts @@ -1,6 +1,6 @@ -import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne } from "typeorm"; - +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, OneToMany } from "typeorm"; import { Status } from "../types/status"; +import { TrxCompanyAccount } from "./trx_company_accounts"; @Entity("trx_companies", { schema: "trx" }) export class TrxCompany { @@ -47,6 +47,9 @@ export class TrxCompany { }) pic_email: string; + @OneToMany(() => TrxCompanyAccount, (company_account) => company_account.company, { cascade: true, nullable: false }) + company_account: TrxCompanyAccount[]; + @Column() @CreateDateColumn() created_at: Date; diff --git a/src/entity/trx_company_accounts.ts b/src/entity/trx_company_accounts.ts index 3ce7d8f..5bf6351 100644 --- a/src/entity/trx_company_accounts.ts +++ b/src/entity/trx_company_accounts.ts @@ -21,8 +21,8 @@ export class TrxCompanyAccount { }) account_number: string; - @ManyToOne(() => TrxCompany, { onDelete: "NO ACTION", nullable: true }) - @JoinTable() + @ManyToOne(() => TrxCompany, (company) => company.company_account, { onDelete: "NO ACTION" }) + @JoinColumn() company: TrxCompany; @ManyToOne(() => TrxCif, { onDelete: "NO ACTION", nullable: true }) diff --git a/src/entity/trx_registration.ts b/src/entity/trx_registration.ts index 8a74c97..d0cd403 100644 --- a/src/entity/trx_registration.ts +++ b/src/entity/trx_registration.ts @@ -15,11 +15,11 @@ export class TrxRegistration { }) code: string; - @ManyToOne(() => TrxCompany, { onDelete: "RESTRICT", nullable: true }) + @ManyToOne(() => TrxCompany, { onDelete: "NO ACTION", nullable: true }) @JoinColumn() company: TrxCompany; - @ManyToOne(() => TrxCif, { onDelete: "RESTRICT", nullable: true }) + @ManyToOne(() => TrxCif, { onDelete: "NO ACTION", nullable: true }) @JoinColumn() cif: TrxCif;