Fix migrations for manual override

This commit is contained in:
goga-m 2017-09-27 12:10:48 +03:00 committed by Josh Harvey
parent bb26c0f458
commit 9877fc8ef0
4 changed files with 332 additions and 98 deletions

View file

@ -197,7 +197,7 @@ app.patch('/api/customer/:id', (req, res, next) => {
if (!req.query.authorizedOverride) return res.status(400).send({Error: 'Requires authorized'})
return customers.patch(req.params.id, {
authorized_override: req.query.authorizedOverride
authorizedOverride: req.query.authorizedOverride
})
.then(r => res.send(r))
.catch(() => res.status(404).send({Error: 'Not found'}))

View file

@ -32,7 +32,7 @@ function get (phone) {
*/
function patch (id, values) {
const sql = 'update customers set authorized_override=$2 where id=$1 returning *'
return db.oneOrNone(sql, [id, values.authorized_override])
return db.oneOrNone(sql, [id, values.authorizedOverride])
}
function getById (id) {
@ -84,7 +84,6 @@ function format (customer) {
value: customer.id_card_image_at
}])
customer.status = status.label
return camelize(customer)
}
@ -102,9 +101,7 @@ function batch () {
where id != $1
order by created desc limit $2`
return db.any(sql, [ anonymous.uuid, NUM_RESULTS ])
.then(customers => {
return _.map(customer => format(customer), customers)
})
.then(_.map(format))
}
module.exports = { add, get, batch, getById, patch}

View file

@ -14,7 +14,7 @@ exports.up = function (next) {
*/
`create type compliance_type as enum
('authorized', 'sms', 'id_card_data', 'id_card_photo', 'sanctions', 'cross_ref', 'front_camera', 'hard_limit')`,
'alter table compliance_authorizations alter column compliance_type type compliance_type using compliance_type::compliance_type',
'alter table compliance_authorizations alter column compliance_type set data type compliance_type using compliance_type::text::compliance_type',
'drop type compliance_types',
"create type verification_type as enum ('verified', 'blocked', 'automatic')",

File diff suppressed because one or more lines are too long