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;