import { MigrationInterface, QueryRunner } from "typeorm";

/**
 * Track Fayda identity verification on drivers: whether the driver's
 * identity was verified through VeriFayda and the OIDC subject it was
 * verified against.
 */
export class AddDriverFaydaVerification1890000000003 implements MigrationInterface {
  name = "AddDriverFaydaVerification1890000000003";

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.drivers
      ADD COLUMN IF NOT EXISTS fayda_verified boolean DEFAULT false,
      ADD COLUMN IF NOT EXISTS fayda_sub varchar
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.drivers
      DROP COLUMN IF EXISTS fayda_verified,
      DROP COLUMN IF EXISTS fayda_sub
    `);
  }
}
