Add device_id to cash_out_actions table (#164)

If a costumer originates a cashOut transaction at one device, and then
redeemed at a different device, the wrong machine would have bills debited from it.

With device_id being saved at the cash_out_actions table the bills can
be properly reconciled.
This commit is contained in:
Rafael Taranto 2018-09-16 03:11:21 -03:00 committed by Josh Harvey
parent 1a8ef31d39
commit 38aa006ecc
2 changed files with 13 additions and 1 deletions

View file

@ -18,7 +18,7 @@ function logActionById (t, action, _rec, txId) {
}
function logAction (t, action, _rec, tx) {
const rec = _.assign(_rec, {action, tx_id: tx.id, redeem: !!tx.redeem})
const rec = _.assign(_rec, {action, tx_id: tx.id, redeem: !!tx.redeem, device_id: tx.deviceId})
const sql = pgp.helpers.insert(rec, null, 'cash_out_actions')
return t.none(sql)

View file

@ -0,0 +1,12 @@
var db = require('./db')
exports.up = function (next) {
var sql = [
"alter table cash_out_actions add device_id text not null default ''"
]
db.multi(sql, next)
}
exports.down = function (next) {
next()
}