mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 17:50:54 +00:00
24 lines
802 B
TypeScript
24 lines
802 B
TypeScript
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
|
|
/**
|
|
* Enforce one driver record per verified Fayda identity. A unique index on
|
|
* fayda_sub blocks a second driver from being created against the same Fayda
|
|
* OIDC subject; NULLs stay distinct so legacy/unverified rows are unaffected.
|
|
*/
|
|
export class AddDriverFaydaSubUnique1890000000006 implements MigrationInterface {
|
|
name = "AddDriverFaydaSubUnique1890000000006";
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "UQ_DRIVERS_FAYDA_SUB"
|
|
ON freight.drivers (fayda_sub)
|
|
`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
DROP INDEX IF EXISTS freight."UQ_DRIVERS_FAYDA_SUB"
|
|
`);
|
|
}
|
|
}
|