-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
|
||
export class AddEstimatedClusterMatching1728554628004 implements MigrationInterface { | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
CREATE TABLE estimated_cluster_matching ( | ||
id SERIAL PRIMARY KEY, | ||
project_id INT NOT NULL, | ||
qf_round_id INT NOT NULL, | ||
matching DOUBLE PRECISION NOT NULL | ||
); | ||
`); | ||
|
||
// Create indexes on the new table | ||
await queryRunner.query(` | ||
CREATE INDEX estimated_cluster_matching_project_id_qfround_id | ||
ON estimated_cluster_matching (project_id, qf_round_id); | ||
`); | ||
|
||
await queryRunner.query(` | ||
CREATE INDEX estimated_cluster_matching_matching | ||
ON estimated_cluster_matching (matching); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
// Revert changes if necessary by dropping the table and restoring the view | ||
await queryRunner.query(` | ||
DROP TABLE IF EXISTS estimated_cluster_matching; | ||
`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Field, ObjectType } from 'type-graphql'; | ||
import { | ||
Column, | ||
Index, | ||
PrimaryGeneratedColumn, | ||
BaseEntity, | ||
Entity, | ||
ManyToOne, | ||
JoinColumn, | ||
} from 'typeorm'; | ||
import { Project } from './project'; | ||
|
||
@Entity('estimated_cluster_matching') | ||
@Index('estimated_cluster_matching_project_id_qfround_id', [ | ||
'projectId', | ||
'qfRoundId', | ||
]) | ||
@Index('estimated_cluster_matching_matching', ['matching']) | ||
@ObjectType() | ||
export class EstimatedClusterMatching extends BaseEntity { | ||
@Field() | ||
@PrimaryGeneratedColumn() | ||
id: number; // New primary key | ||
|
||
@Field(_type => Project) | ||
@ManyToOne(_type => Project, project => project.projectEstimatedMatchingView) | ||
@JoinColumn({ referencedColumnName: 'id' }) | ||
project: Project; | ||
|
||
@Field() | ||
@Column() | ||
projectId: number; | ||
|
||
@Field() | ||
@Column() | ||
qfRoundId: number; | ||
|
||
@Field() | ||
@Column('double precision') | ||
matching: number; | ||
} |