diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/006.Insert wake and ping configs for the rest of machines.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/006.Insert wake and ping configs for the rest of machines.sql new file mode 100644 index 0000000..a4805f7 --- /dev/null +++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/006.Insert wake and ping configs for the rest of machines.sql @@ -0,0 +1,18 @@ +declare @server_performer_id int, @wake_action_id int, @ping_action_id int +select @server_performer_id = PerformerId from PowerActionPerformer where PerformerCode = 'NETWORK_RESURRECTOR_SERVER' +select @wake_action_id = PowerActionId from PowerAction where PowerActionCode = 'WAKE' +select @ping_action_id = PowerActionId from PowerAction where PowerActionCode = 'PING' + +-- insert WAKE configuration for all machine that don't have it +insert into PowerActionConfiguration (MachineId, PowerActionId, PerformerId) +select m.MachineId, @wake_action_id, @server_performer_id +from Machine m +left join PowerActionConfiguration c on m.MachineId = c.MachineId and c.PowerActionId = @wake_action_id +where c.ConfigurationId is null + +-- insert PING configuration for all machine that don't have it +insert into PowerActionConfiguration (MachineId, PowerActionId, PerformerId) +select m.MachineId, @ping_action_id, @server_performer_id +from Machine m +left join PowerActionConfiguration c on m.MachineId = c.MachineId and c.PowerActionId = @ping_action_id +where c.ConfigurationId is null