Merge pull request #1715 from RafaelTaranto/fix/fkey-on-device-id
LAM-1151 fix: fkeys on device_id
This commit is contained in:
commit
3956c419b5
3 changed files with 15 additions and 1 deletions
|
|
@ -49,6 +49,7 @@ const getDefaultSchema = () => 'ERROR_SCHEMA'
|
|||
const searchPathWrapper = (t, cb) => {
|
||||
return t.none('SET search_path TO $1:name', [getSchema()])
|
||||
.then(cb.bind(t, t))
|
||||
.catch(logger.error)
|
||||
.finally(() => t.none('SET search_path TO $1:name', [getDefaultSchema()]))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ function unpair (deviceId) {
|
|||
const q2 = t.none(`DELETE FROM machine_pings WHERE device_id=$1`, [deviceId])
|
||||
const q3 = t.none(`DELETE FROM machine_network_heartbeat WHERE device_id=$1`, [deviceId])
|
||||
const q4 = t.none(`DELETE FROM machine_network_performance WHERE device_id=$1`, [deviceId])
|
||||
return t.batch([q1, q2, q3, q4])
|
||||
const q5 = t.none(`DELETE FROM machine_diagnostics WHERE device_id=$1`, [deviceId])
|
||||
return t.batch([q1, q2, q3, q4, q5])
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
|
|||
12
migrations/1724242113482-drop-last-used-fkey.js
Normal file
12
migrations/1724242113482-drop-last-used-fkey.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
const db = require('./db')
|
||||
|
||||
exports.up = function (next) {
|
||||
db.multi([
|
||||
'ALTER TABLE customers DROP CONSTRAINT customers_last_used_machine_fkey;',
|
||||
'ALTER TABLE machine_diagnostics DROP CONSTRAINT machine_diagnostics_device_id_fkey;'
|
||||
], next)
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue