import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Wagon status RETIRED is renamed DETAINED (wagons pulled from circulation).
 * The column is a plain varchar, so this is a data-only rename. Vehicles keep
 * their own RETIRED status — only freight.wagons rows are touched.
 */
export class RenameWagonStatusRetiredToDetained2230000000000
  implements MigrationInterface
{
  name = 'RenameWagonStatusRetiredToDetained2230000000000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      UPDATE freight.wagons SET status = 'DETAINED' WHERE status = 'RETIRED'
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      UPDATE freight.wagons SET status = 'RETIRED' WHERE status = 'DETAINED'
    `);
  }
}
