Fix alerts page by migrating old equipment_* alert types to device_*
The Alert schema was updated to use :device_down and :device_up enum values, but existing database records still had 'equipment_down' and 'equipment_up' values. Added migration to update all existing alert records to use the new naming convention.
This commit is contained in:
parent
a6fb2ef833
commit
412086d7ec
1 changed files with 15 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
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
|
||||
Loading…
Add table
Reference in a new issue