diff --git a/packages/data-store/src/entities/contact/BaseContactEntity.ts b/packages/data-store/src/entities/contact/BaseContactEntity.ts index 64f219243..d0f548eb0 100644 --- a/packages/data-store/src/entities/contact/BaseContactEntity.ts +++ b/packages/data-store/src/entities/contact/BaseContactEntity.ts @@ -1,4 +1,6 @@ -import { BaseEntity, CreateDateColumn, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, TableInheritance, UpdateDateColumn } from 'typeorm' +import { BaseEntity, + BeforeInsert, + BeforeUpdate, CreateDateColumn, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, TableInheritance, UpdateDateColumn } from 'typeorm' import { PartyEntity } from './PartyEntity' @Entity('BaseContact') @@ -18,4 +20,11 @@ export abstract class BaseContactEntity extends BaseEntity { }) @JoinColumn({ name: 'party_id' }) party!: PartyEntity + + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } } diff --git a/packages/data-store/src/entities/contact/ElectronicAddressEntity.ts b/packages/data-store/src/entities/contact/ElectronicAddressEntity.ts index d2d60914e..ba633bd99 100644 --- a/packages/data-store/src/entities/contact/ElectronicAddressEntity.ts +++ b/packages/data-store/src/entities/contact/ElectronicAddressEntity.ts @@ -38,6 +38,13 @@ export class ElectronicAddressEntity extends BaseEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async validate(): Promise { diff --git a/packages/data-store/src/entities/contact/IdentityEntity.ts b/packages/data-store/src/entities/contact/IdentityEntity.ts index e3db4ba5c..356f528f0 100644 --- a/packages/data-store/src/entities/contact/IdentityEntity.ts +++ b/packages/data-store/src/entities/contact/IdentityEntity.ts @@ -75,6 +75,13 @@ export class IdentityEntity extends BaseEntity { @Column({ name: 'partyId', nullable: true }) partyId!: string + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async validate(): Promise { diff --git a/packages/data-store/src/entities/contact/PartyEntity.ts b/packages/data-store/src/entities/contact/PartyEntity.ts index db7adc9de..43bb09279 100644 --- a/packages/data-store/src/entities/contact/PartyEntity.ts +++ b/packages/data-store/src/entities/contact/PartyEntity.ts @@ -78,6 +78,13 @@ export class PartyEntity extends BaseEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async checkUniqueTenantId(): Promise { diff --git a/packages/data-store/src/entities/contact/PartyRelationshipEntity.ts b/packages/data-store/src/entities/contact/PartyRelationshipEntity.ts index 7807b2058..2cc482262 100644 --- a/packages/data-store/src/entities/contact/PartyRelationshipEntity.ts +++ b/packages/data-store/src/entities/contact/PartyRelationshipEntity.ts @@ -44,6 +44,13 @@ export class PartyRelationshipEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async checkRelationshipSides(): Promise { diff --git a/packages/data-store/src/entities/contact/PartyTypeEntity.ts b/packages/data-store/src/entities/contact/PartyTypeEntity.ts index 472628203..8436b615d 100644 --- a/packages/data-store/src/entities/contact/PartyTypeEntity.ts +++ b/packages/data-store/src/entities/contact/PartyTypeEntity.ts @@ -37,6 +37,13 @@ export class PartyTypeEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async validate(): Promise { diff --git a/packages/data-store/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts b/packages/data-store/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts index f60a96101..6435f9e83 100644 --- a/packages/data-store/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +++ b/packages/data-store/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts @@ -67,6 +67,13 @@ export class BaseLocaleBrandingEntity extends BaseEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async validate(): Promise { diff --git a/packages/data-store/src/entities/issuanceBranding/CredentialBrandingEntity.ts b/packages/data-store/src/entities/issuanceBranding/CredentialBrandingEntity.ts index 178d01521..b1161044a 100644 --- a/packages/data-store/src/entities/issuanceBranding/CredentialBrandingEntity.ts +++ b/packages/data-store/src/entities/issuanceBranding/CredentialBrandingEntity.ts @@ -48,6 +48,13 @@ export class CredentialBrandingEntity extends BaseEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async validate(): Promise { diff --git a/packages/data-store/src/entities/issuanceBranding/IssuerBrandingEntity.ts b/packages/data-store/src/entities/issuanceBranding/IssuerBrandingEntity.ts index e3e83ba44..404e94d2d 100644 --- a/packages/data-store/src/entities/issuanceBranding/IssuerBrandingEntity.ts +++ b/packages/data-store/src/entities/issuanceBranding/IssuerBrandingEntity.ts @@ -43,6 +43,13 @@ export class IssuerBrandingEntity extends BaseEntity { @UpdateDateColumn({ name: 'last_updated_at', nullable: false }) lastUpdatedAt!: Date + // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change. + @BeforeInsert() + @BeforeUpdate() + updateUpdatedDate(): void { + this.lastUpdatedAt = new Date() + } + @BeforeInsert() @BeforeUpdate() async validate(): Promise {