Skip to content

Commit

Permalink
perf: add indices to planning areas
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyostiq committed Jun 30, 2021
1 parent 24dbefe commit b25bbbe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddIndicesToPlanningArea1625037619200
implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE INDEX planning_areas_project_id__idx ON "planning_areas" ("project_id") `,
);
await queryRunner.query(
`CREATE INDEX planning_areas_created_at__idx ON "planning_areas" ("created_at") `,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX planning_areas_created_at__idx`);
await queryRunner.query(`DROP INDEX planning_areas_project_id__idx`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Column,
CreateDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
Expand All @@ -21,6 +22,7 @@ export class PlanningArea {
nullable: true,
name: 'project_id',
})
@Index()
projectId?: string | null;

@ApiProperty()
Expand All @@ -41,5 +43,6 @@ export class PlanningArea {
name: 'created_at',
type: 'timestamp without time zone',
})
@Index()
createdAt!: Date;
}

0 comments on commit b25bbbe

Please sign in to comment.