defmodule Towerops.Repo.Migrations.UpdateAlertTypesEquipmentToDevice do
  use Ecto.Migration

  def up do
    # Update existing alert records from old "equipment_*" naming to "device_*" naming
    execute("UPDATE alerts SET alert_type = 'device_down' WHERE alert_type = 'equipment_down'")
    execute("UPDATE alerts SET alert_type = 'device_up' WHERE alert_type = 'equipment_up'")
  end

  def down do
    # Revert back to old naming if needed
    execute("UPDATE alerts SET alert_type = 'equipment_down' WHERE alert_type = 'device_down'")
    execute("UPDATE alerts SET alert_type = 'equipment_up' WHERE alert_type = 'device_up'")
  end
end
