From dc575374db05bd8c194c6ae3f84b28fb0f2302ce Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 22 Jan 2025 14:46:14 +0100 Subject: [PATCH] add uniquness constraint to estimatedclustedMatching --- ...addUniquenessToEstimatedClusterMatching.ts | 22 +++++++++++++++++++ src/entities/estimatedClusterMatching.ts | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 migration/1737553475189-addUniquenessToEstimatedClusterMatching.ts diff --git a/migration/1737553475189-addUniquenessToEstimatedClusterMatching.ts b/migration/1737553475189-addUniquenessToEstimatedClusterMatching.ts new file mode 100644 index 000000000..e8577d282 --- /dev/null +++ b/migration/1737553475189-addUniquenessToEstimatedClusterMatching.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner, TableUnique } from 'typeorm'; + +export class addUniquenessToEstimatedClusterMatching1737553475189 + implements MigrationInterface +{ + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.createUniqueConstraint( + 'estimated_cluster_matching', + new TableUnique({ + name: 'unique_projectId_qfRoundId', + columnNames: ['projectId', 'qfRoundId'], + }), + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropUniqueConstraint( + 'estimated_cluster_matching', + 'unique_projectId_qfRoundId', + ); + } +} diff --git a/src/entities/estimatedClusterMatching.ts b/src/entities/estimatedClusterMatching.ts index da2165e8e..4372a5bcc 100644 --- a/src/entities/estimatedClusterMatching.ts +++ b/src/entities/estimatedClusterMatching.ts @@ -7,6 +7,7 @@ import { Entity, ManyToOne, JoinColumn, + Unique, } from 'typeorm'; import { Project } from './project'; @@ -15,6 +16,7 @@ import { Project } from './project'; 'projectId', 'qfRoundId', ]) +@Unique('unique_projectId_qfRoundId', ['projectId', 'qfRoundId']) @Index('estimated_cluster_matching_matching', ['matching']) @ObjectType() export class EstimatedClusterMatching extends BaseEntity {