import { MigrationInterface, QueryRunner } from "typeorm";

/**
 * The person who signs off a handover must record their full name (a signature
 * is optional, especially for self-haul). Stored per handover record.
 */
export class AddHandoverSignerName2130000000000 implements MigrationInterface {
  name = "AddHandoverSignerName2130000000000";

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.booking_handovers
        ADD COLUMN IF NOT EXISTS signer_name varchar(160)
    `);
  }

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