import { MigrationInterface, QueryRunner } from "typeorm";

/**
 * Add location_id column to vehicles table to track vehicle base location.
 */
export class AddLocationToVehicles1870000000000 implements MigrationInterface {
  name = "AddLocationToVehicles1870000000000";

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.vehicles
        ADD COLUMN IF NOT EXISTS location_id uuid;
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.vehicles
        DROP COLUMN IF EXISTS location_id;
    `);
  }
}
