import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * New built-train lifecycle status DEACTIVATED: staff park a train indefinitely
 * (only allowed while it has no DRAFT/SCHEDULED/DISPATCHED schedule). Like
 * UNDER_MAINTENANCE / OUT_OF_SERVICE it is staff-owned — the scheduler never
 * overwrites it and refuses to schedule a deactivated train.
 *
 * Postgres cannot drop an enum value, so down() is a no-op.
 */
export class AddTrainDeactivatedStatus2380000000000 implements MigrationInterface {
  name = 'AddTrainDeactivatedStatus2380000000000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TYPE "freight"."train_status" ADD VALUE IF NOT EXISTS 'DEACTIVATED'`,
    );
  }

  public async down(): Promise<void> {
    // Enum values cannot be removed in Postgres; leaving the label is harmless.
  }
}
