import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Movement Dashboard activity add-ons (2026-10-15). A guest outside the
 * booking's party can join one activity from the dashboard; the extra
 * pax are billed as a separate customer settlement row and the booking's
 * own pax / total stay unchanged. Stored per activity line (fanned out
 * across its age-group rows like the pax overrides).
 */
export class ActivityAddonPax1788100000000 implements MigrationInterface {
  name = 'ActivityAddonPax1788100000000';

  public async up(qr: QueryRunner): Promise<void> {
    await qr.query(`
      ALTER TABLE "booking_activity_items"
        ADD COLUMN IF NOT EXISTS "addon_adults" integer NOT NULL DEFAULT 0,
        ADD COLUMN IF NOT EXISTS "addon_children" integer NOT NULL DEFAULT 0,
        ADD COLUMN IF NOT EXISTS "addon_billed_amount" numeric(12,2) NOT NULL DEFAULT 0
    `);
  }

  public async down(qr: QueryRunner): Promise<void> {
    await qr.query(`ALTER TABLE "booking_activity_items" DROP COLUMN IF EXISTS "addon_billed_amount"`);
    await qr.query(`ALTER TABLE "booking_activity_items" DROP COLUMN IF EXISTS "addon_children"`);
    await qr.query(`ALTER TABLE "booking_activity_items" DROP COLUMN IF EXISTS "addon_adults"`);
  }
}
