From 5c8b27bb29b8a859825a1c0ee1dde57664c45574 Mon Sep 17 00:00:00 2001 From: "fazri.is" Date: Thu, 2 Oct 2025 13:10:40 +0700 Subject: [PATCH 1/2] update --- src/entity/trx_companies.ts | 6 +++++- src/entity/trx_company_users.ts | 4 ++-- src/entity/trx_config_booms.ts | 4 ---- src/entity/trx_config_business_entities.ts | 4 ---- src/entity/trx_config_business_fields.ts | 4 ---- src/entity/trx_config_channels.ts | 4 ---- src/entity/trx_config_educations.ts | 4 ---- src/entity/trx_config_identity_types.ts | 4 ---- src/entity/trx_config_nationalities.ts | 4 ---- src/entity/trx_config_occupations.ts | 4 ---- src/entity/trx_config_products.ts | 4 ---- src/entity/trx_config_purposes.ts | 4 ---- src/entity/trx_config_relations.ts | 4 ---- src/entity/trx_config_religions.ts | 4 ---- src/entity/trx_config_source_incomes.ts | 4 ---- src/entity/trx_config_strs.ts | 4 ---- 16 files changed, 7 insertions(+), 59 deletions(-) diff --git a/src/entity/trx_companies.ts b/src/entity/trx_companies.ts index 7104a10..120141e 100644 --- a/src/entity/trx_companies.ts +++ b/src/entity/trx_companies.ts @@ -1,6 +1,7 @@ -import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, OneToMany } from "typeorm"; +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, OneToMany, OneToOne } from "typeorm"; import { Status } from "../types/status"; import { TrxCompanyAccount } from "./trx_company_accounts"; +import { TrxCompanyUser } from "./trx_company_users"; @Entity("trx_companies", { schema: "trx" }) export class TrxCompany { @@ -50,6 +51,9 @@ export class TrxCompany { @OneToMany(() => TrxCompanyAccount, (company_account) => company_account.company, { cascade: true, nullable: false }) company_account: TrxCompanyAccount[]; + @OneToOne(() => TrxCompanyUser, (company_user) => company_user.company, { onDelete: "CASCADE" }) + user: TrxCompanyUser; + @Column() @CreateDateColumn() created_at: Date; diff --git a/src/entity/trx_company_users.ts b/src/entity/trx_company_users.ts index b9a74cf..8768924 100644 --- a/src/entity/trx_company_users.ts +++ b/src/entity/trx_company_users.ts @@ -48,8 +48,8 @@ export class TrxCompanyUser { @OneToMany(() => TrxConfigLevel, (level) => level.id, { onDelete: "NO ACTION", nullable: false }) level: TrxConfigLevel[]; - @ManyToOne(() => TrxCompany, { onDelete: "NO ACTION" }) - @JoinTable() + @OneToOne(() => TrxCompany, (company) => company.user, { cascade: true }) + @JoinColumn() company: TrxCompany; @Index() diff --git a/src/entity/trx_config_booms.ts b/src/entity/trx_config_booms.ts index b1c2a14..adbeefb 100644 --- a/src/entity/trx_config_booms.ts +++ b/src/entity/trx_config_booms.ts @@ -16,10 +16,6 @@ export class TrxConfigBoom { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_business_entities.ts b/src/entity/trx_config_business_entities.ts index b8ce97d..9970481 100644 --- a/src/entity/trx_config_business_entities.ts +++ b/src/entity/trx_config_business_entities.ts @@ -16,10 +16,6 @@ export class TrxConfigBusinessEntity { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_business_fields.ts b/src/entity/trx_config_business_fields.ts index 72316e9..716eae5 100644 --- a/src/entity/trx_config_business_fields.ts +++ b/src/entity/trx_config_business_fields.ts @@ -16,10 +16,6 @@ export class TrxConfigBusinessField { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_channels.ts b/src/entity/trx_config_channels.ts index 1581589..27f591b 100644 --- a/src/entity/trx_config_channels.ts +++ b/src/entity/trx_config_channels.ts @@ -16,10 +16,6 @@ export class TrxConfigChannel { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_educations.ts b/src/entity/trx_config_educations.ts index 5b9d134..d4c580b 100644 --- a/src/entity/trx_config_educations.ts +++ b/src/entity/trx_config_educations.ts @@ -16,10 +16,6 @@ export class TrxConfigEducation { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_identity_types.ts b/src/entity/trx_config_identity_types.ts index d5bced2..d25f577 100644 --- a/src/entity/trx_config_identity_types.ts +++ b/src/entity/trx_config_identity_types.ts @@ -16,10 +16,6 @@ export class TrxConfigIdentityType { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_nationalities.ts b/src/entity/trx_config_nationalities.ts index eb1067f..50fa1eb 100644 --- a/src/entity/trx_config_nationalities.ts +++ b/src/entity/trx_config_nationalities.ts @@ -16,10 +16,6 @@ export class TrxConfigNationality { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: true, length: 256, diff --git a/src/entity/trx_config_occupations.ts b/src/entity/trx_config_occupations.ts index 49ddf0d..a41128f 100644 --- a/src/entity/trx_config_occupations.ts +++ b/src/entity/trx_config_occupations.ts @@ -16,10 +16,6 @@ export class TrxConfigOccupation { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_products.ts b/src/entity/trx_config_products.ts index f61296d..a7f1980 100644 --- a/src/entity/trx_config_products.ts +++ b/src/entity/trx_config_products.ts @@ -16,10 +16,6 @@ export class TrxConfigProduct { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_purposes.ts b/src/entity/trx_config_purposes.ts index e92a418..eb1adf4 100644 --- a/src/entity/trx_config_purposes.ts +++ b/src/entity/trx_config_purposes.ts @@ -16,10 +16,6 @@ export class TrxConfigPurpose { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_relations.ts b/src/entity/trx_config_relations.ts index 0ba8c12..2ca806a 100644 --- a/src/entity/trx_config_relations.ts +++ b/src/entity/trx_config_relations.ts @@ -16,10 +16,6 @@ export class TrxConfigRelation { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_religions.ts b/src/entity/trx_config_religions.ts index 71da474..c7c6189 100644 --- a/src/entity/trx_config_religions.ts +++ b/src/entity/trx_config_religions.ts @@ -16,10 +16,6 @@ export class TrxConfigReligion { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_source_incomes.ts b/src/entity/trx_config_source_incomes.ts index 32fe71a..0d7bf1b 100644 --- a/src/entity/trx_config_source_incomes.ts +++ b/src/entity/trx_config_source_incomes.ts @@ -16,10 +16,6 @@ export class TrxConfigSourceIncome { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_config_strs.ts b/src/entity/trx_config_strs.ts index 49ad3a1..0be902d 100644 --- a/src/entity/trx_config_strs.ts +++ b/src/entity/trx_config_strs.ts @@ -16,10 +16,6 @@ export class TrxConfigStr { @Column({ type: "smallint", default: 0 }) level: Number; - @ManyToOne(() => TrxLanguage, { onDelete: "RESTRICT", nullable: true }) - @JoinColumn() - language: TrxLanguage; - @Column({ nullable: false, length: 64, From ec0ebd02ee28caf8d4a3d89246e02dfe527c7213 Mon Sep 17 00:00:00 2001 From: "fazri.is" Date: Thu, 2 Oct 2025 13:40:05 +0700 Subject: [PATCH 2/2] update --- src/entity/trx_companies.ts | 6 +----- src/entity/trx_company_users.ts | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/entity/trx_companies.ts b/src/entity/trx_companies.ts index 120141e..7104a10 100644 --- a/src/entity/trx_companies.ts +++ b/src/entity/trx_companies.ts @@ -1,7 +1,6 @@ -import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, OneToMany, OneToOne } 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"; -import { TrxCompanyUser } from "./trx_company_users"; @Entity("trx_companies", { schema: "trx" }) export class TrxCompany { @@ -51,9 +50,6 @@ export class TrxCompany { @OneToMany(() => TrxCompanyAccount, (company_account) => company_account.company, { cascade: true, nullable: false }) company_account: TrxCompanyAccount[]; - @OneToOne(() => TrxCompanyUser, (company_user) => company_user.company, { onDelete: "CASCADE" }) - user: TrxCompanyUser; - @Column() @CreateDateColumn() created_at: Date; diff --git a/src/entity/trx_company_users.ts b/src/entity/trx_company_users.ts index 8768924..b9a74cf 100644 --- a/src/entity/trx_company_users.ts +++ b/src/entity/trx_company_users.ts @@ -48,8 +48,8 @@ export class TrxCompanyUser { @OneToMany(() => TrxConfigLevel, (level) => level.id, { onDelete: "NO ACTION", nullable: false }) level: TrxConfigLevel[]; - @OneToOne(() => TrxCompany, (company) => company.user, { cascade: true }) - @JoinColumn() + @ManyToOne(() => TrxCompany, { onDelete: "NO ACTION" }) + @JoinTable() company: TrxCompany; @Index()