Skip to content

Commit 9803782

Browse files
committed
join column and idx
1 parent f69d987 commit 9803782

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/entity/user/User.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,10 @@ export class User {
345345
locationId: string | null;
346346

347347
@ManyToOne('DatasetLocation', { lazy: true })
348+
@JoinColumn({
349+
name: 'locationId',
350+
foreignKeyConstraintName: 'FK_user_locationId',
351+
})
352+
@Index('IDX_user_locationId')
348353
location: Promise<DatasetLocation>;
349354
}

src/migration/1760354446019-UserLocationId.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ export class UserLocationId1760354446019 implements MigrationInterface {
88
await queryRunner.query(
99
`ALTER TABLE "user" ADD CONSTRAINT "FK_user_locationId" FOREIGN KEY ("locationId") REFERENCES "dataset_location"("id") ON DELETE SET NULL ON UPDATE NO ACTION`,
1010
);
11+
await queryRunner.query(
12+
`CREATE INDEX "IDX_user_locationId" ON "user" ("locationId")`,
13+
);
1114
}
1215

1316
public async down(queryRunner: QueryRunner): Promise<void> {
17+
await queryRunner.query(`DROP INDEX "IDX_user_locationId"`);
1418
await queryRunner.query(
1519
`ALTER TABLE "user" DROP CONSTRAINT "FK_user_locationId"`,
1620
);

0 commit comments

Comments
 (0)