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

/**
 * "Mark as Guarantee" flag on bookings. When true, the Movement
 * Dashboard skips the day-wise payment gate and unlocks every route
 * on the booking regardless of customer collections. The optional
 * description records why ops vouched for the customer.
 */
export class BookingIsGuaranteed1787000000000 implements MigrationInterface {
  name = 'BookingIsGuaranteed1787000000000';

  public async up(qr: QueryRunner): Promise<void> {
    await qr.query(`
      ALTER TABLE "bookings"
        ADD COLUMN IF NOT EXISTS "is_guaranteed" boolean NOT NULL DEFAULT false,
        ADD COLUMN IF NOT EXISTS "guarantee_description" text NULL
    `);
  }

  public async down(qr: QueryRunner): Promise<void> {
    await qr.query(`
      ALTER TABLE "bookings"
        DROP COLUMN IF EXISTS "guarantee_description",
        DROP COLUMN IF EXISTS "is_guaranteed"
    `);
  }
}
