import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

/**
 * Adds reviewer note/id/timestamp to company_profiles so a rejected operational
 * role (new ProfileStatus 'rejected') can carry the reason back to the customer,
 * who can then amend and reapply.
 */
export class AddCompanyProfileReview2000000000001
  implements MigrationInterface
{
  name = 'AddCompanyProfileReview2000000000001';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumns('freight.company_profiles', [
      new TableColumn({ name: 'review_note', type: 'text', isNullable: true }),
      new TableColumn({ name: 'reviewed_by', type: 'uuid', isNullable: true }),
      new TableColumn({ name: 'reviewed_at', type: 'timestamptz', isNullable: true }),
    ]);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropColumns('freight.company_profiles', [
      'review_note',
      'reviewed_by',
      'reviewed_at',
    ]);
  }
}
