import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Ops alert window (client 2026-11-18): a change request that changes a
 * service dated within this many days (0 = today only, 1 = today +
 * tomorrow …) notifies the ops approvers and is flagged "Travels …" in
 * Approvals. Admin sets it in Settings; default 1 (tomorrow).
 */
export class OpsAlertWindowDays1789600000000 implements MigrationInterface {
  name = 'OpsAlertWindowDays1789600000000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "tenant_settings" ADD COLUMN IF NOT EXISTS "ops_alert_window_days" integer NOT NULL DEFAULT 1`,
    );
  }

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