Delete machine pings on unpair

This commit is contained in:
Rafael Taranto 2019-05-27 22:47:01 -03:00 committed by Josh Harvey
parent 8330b95de1
commit 09332c37db
2 changed files with 4 additions and 1 deletions

View file

@ -37,7 +37,8 @@ function removeDeviceConfig (deviceId) {
function unpair (deviceId) {
const sql = 'delete from devices where device_id=$1'
return db.none(sql, [deviceId])
const deleteMachinePings = 'delete from machine_pings where device_id=$1'
return Promise.all([db.none(sql, [deviceId]), db.none(deleteMachinePings, [deviceId])])
.then(() => removeDeviceConfig(deviceId))
}