From b6321c253058f18ebe5d78a6d8909b042e6ff5db Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Tue, 10 Jun 2025 01:18:58 -0600 Subject: [PATCH 1/2] Refactor DeviceStatusLogEntity: update unique constraint to include deviceId --- .../device-status-log/entities/device-status-log.entity.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts b/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts index b40c393..a97565a 100644 --- a/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts +++ b/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts @@ -2,15 +2,15 @@ import { SourceType } from '@app/common/constants/source-type.enum'; import { Entity, Column, PrimaryColumn, Unique } from 'typeorm'; @Entity('device-status-log') -@Unique('event_time_idx', ['eventTime']) +@Unique('event_time_device_idx', ['eventTime', 'deviceId']) export class DeviceStatusLogEntity { - @Column({ type: 'int', generated: true, unsigned: true }) + @PrimaryColumn({ type: 'int', generated: true, unsigned: true }) id: number; @Column({ type: 'text' }) eventId: string; - @PrimaryColumn({ type: 'timestamptz' }) + @Column({ type: 'timestamptz' }) eventTime: Date; @Column({ From 0793441e06534b2b1ade526c1516ed5478c1deaf Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Tue, 10 Jun 2025 01:24:33 -0600 Subject: [PATCH 2/2] Refactor DeviceStatusLogEntity: correct unique constraint name for event time and device ID --- .../device-status-log/entities/device-status-log.entity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts b/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts index a97565a..3b55e31 100644 --- a/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts +++ b/libs/common/src/modules/device-status-log/entities/device-status-log.entity.ts @@ -2,7 +2,7 @@ import { SourceType } from '@app/common/constants/source-type.enum'; import { Entity, Column, PrimaryColumn, Unique } from 'typeorm'; @Entity('device-status-log') -@Unique('event_time_device_idx', ['eventTime', 'deviceId']) +@Unique('event_time_idx', ['eventTime', 'deviceId']) export class DeviceStatusLogEntity { @PrimaryColumn({ type: 'int', generated: true, unsigned: true }) id: number;