import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Persist the signer's saved-signature image on the handover record, so the
 * signed handover document can render the actual signature (not just the
 * typed name) — parity with the booking-contract signing flow.
 */
export class AddSignatureToHandover2800000000001 implements MigrationInterface {
  name = 'AddSignatureToHandover2800000000001';

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

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