Merge pull request #1877 from siiky/feat/lam-1291/stress-testing
LAM-1291 feat: stress testing scripts and some performance improvements
This commit is contained in:
commit
22938ab594
166 changed files with 1207 additions and 95813 deletions
|
|
@ -47,9 +47,13 @@ function updateCore(coinRec, isCurrentlyRunning) {
|
||||||
`grep "i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=" /mnt/blockchains/zcash/zcash.conf || true`,
|
`grep "i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=" /mnt/blockchains/zcash/zcash.conf || true`,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
common.logger.info(`i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025 already defined, skipping...`)
|
common.logger.info(
|
||||||
|
`i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025 already defined, skipping...`,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
common.logger.info(`Setting 'i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=1' in config file...`)
|
common.logger.info(
|
||||||
|
`Setting 'i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=1' in config file...`,
|
||||||
|
)
|
||||||
common.es(
|
common.es(
|
||||||
`echo "\ni-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=1" >> /mnt/blockchains/zcash/zcash.conf`,
|
`echo "\ni-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=1" >> /mnt/blockchains/zcash/zcash.conf`,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,13 @@ function getMachineName(machineId) {
|
||||||
return db.oneOrNone(sql, [machineId]).then(it => it?.name)
|
return db.oneOrNone(sql, [machineId]).then(it => it?.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getPairedMachineName = deviceId =>
|
||||||
|
db.oneOrNone(
|
||||||
|
'SELECT name FROM devices WHERE device_id = $1 AND paired = TRUE',
|
||||||
|
[deviceId],
|
||||||
|
machine => machine?.name,
|
||||||
|
)
|
||||||
|
|
||||||
function getMachine(machineId, config) {
|
function getMachine(machineId, config) {
|
||||||
const sql = `${MACHINE_WITH_CALCULATED_FIELD_SQL} WHERE d.device_id = $1`
|
const sql = `${MACHINE_WITH_CALCULATED_FIELD_SQL} WHERE d.device_id = $1`
|
||||||
|
|
||||||
|
|
@ -702,8 +709,55 @@ function updatePhotos(dir, photoPairs) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let pendingRecordPings = new Map()
|
||||||
|
const enqueueRecordPing = ping => {
|
||||||
|
pendingRecordPings.set(ping.deviceId, ping)
|
||||||
|
}
|
||||||
|
|
||||||
|
// from @sindresorhus/is-empty-iterable
|
||||||
|
const isEmptyIterable = iter => {
|
||||||
|
for (const _ of iter) return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
const batchRecordPendingPings = () => {
|
||||||
|
let pings = pendingRecordPings.values()
|
||||||
|
pendingRecordPings = new Map()
|
||||||
|
if (isEmptyIterable(pings)) return Promise.resolve()
|
||||||
|
|
||||||
|
const prepareChunk = (t, chunk) =>
|
||||||
|
chunk
|
||||||
|
.flatMap(({ deviceId, last_online, version, model }) => [
|
||||||
|
t.none(
|
||||||
|
`INSERT INTO machine_pings (device_id, device_time)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
ON CONFLICT (device_id) DO
|
||||||
|
UPDATE SET device_time = $2,
|
||||||
|
updated = now()`,
|
||||||
|
[deviceId, last_online],
|
||||||
|
),
|
||||||
|
t.none(
|
||||||
|
pgp.helpers.update({ last_online, version, model }, null, 'devices') +
|
||||||
|
'WHERE device_id = ${deviceId}',
|
||||||
|
{ deviceId },
|
||||||
|
),
|
||||||
|
])
|
||||||
|
.toArray()
|
||||||
|
|
||||||
|
const MaxBatchSize = 500
|
||||||
|
return db
|
||||||
|
.task(async t => {
|
||||||
|
while (!isEmptyIterable(pings)) {
|
||||||
|
const chunk = pings.take(MaxBatchSize)
|
||||||
|
await t.batch(prepareChunk(t, chunk)).catch(err => logger.error(err))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => logger.error(err))
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getMachineName,
|
getMachineName,
|
||||||
|
getPairedMachineName,
|
||||||
getMachines,
|
getMachines,
|
||||||
getUnpairedMachines,
|
getUnpairedMachines,
|
||||||
getMachine,
|
getMachine,
|
||||||
|
|
@ -719,4 +773,6 @@ module.exports = {
|
||||||
updateDiagnostics,
|
updateDiagnostics,
|
||||||
updateFailedQRScans,
|
updateFailedQRScans,
|
||||||
batchDiagnostics,
|
batchDiagnostics,
|
||||||
|
enqueueRecordPing,
|
||||||
|
batchRecordPendingPings,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
const pairing = require('../pairing')
|
const { getPairedMachineName } = require('../machine-loader')
|
||||||
const logger = require('../logger')
|
const logger = require('../logger')
|
||||||
|
|
||||||
const authorize = function (req, res, next) {
|
const authorize = function (req, res, next) {
|
||||||
return pairing
|
return getPairedMachineName(req.deviceId)
|
||||||
.isPaired(req.deviceId)
|
|
||||||
.then(deviceName => {
|
.then(deviceName => {
|
||||||
if (deviceName) {
|
if (deviceName) {
|
||||||
req.deviceName = deviceName
|
req.deviceName = deviceName
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
|
||||||
|
//const IS_STRESS_TESTING = process.env.LAMASSU_STRESS_TESTING === 'YES'
|
||||||
|
|
||||||
function sha256(buf) {
|
function sha256(buf) {
|
||||||
if (!buf) return null
|
if (!buf) return null
|
||||||
const hash = crypto.createHash('sha256')
|
const hash = crypto.createHash('sha256')
|
||||||
|
|
@ -12,7 +14,9 @@ const populateDeviceId = function (req, res, next) {
|
||||||
const peerCert = req.socket.getPeerCertificate
|
const peerCert = req.socket.getPeerCertificate
|
||||||
? req.socket.getPeerCertificate()
|
? req.socket.getPeerCertificate()
|
||||||
: null
|
: null
|
||||||
const deviceId = peerCert?.raw ? sha256(peerCert.raw) : null
|
let deviceId = peerCert?.raw ? sha256(peerCert.raw) : null
|
||||||
|
|
||||||
|
//if (!deviceId && IS_STRESS_TESTING) deviceId = req.headers.device_id
|
||||||
|
|
||||||
if (!deviceId)
|
if (!deviceId)
|
||||||
return res.status(500).json({ error: 'Unable to find certificate' })
|
return res.status(500).json({ error: 'Unable to find certificate' })
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,6 @@ const populateSettings = function (req, res, next) {
|
||||||
const { needsSettingsReload, settingsCache } = state
|
const { needsSettingsReload, settingsCache } = state
|
||||||
const operatorId = res.locals.operatorId
|
const operatorId = res.locals.operatorId
|
||||||
const versionId = req.headers['config-version']
|
const versionId = req.headers['config-version']
|
||||||
if (versionId !== state.oldVersionId) {
|
|
||||||
state.oldVersionId = versionId
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Priority of configs to retrieve
|
// Priority of configs to retrieve
|
||||||
|
|
@ -113,7 +110,7 @@ const populateSettings = function (req, res, next) {
|
||||||
|
|
||||||
const operatorSettings = settingsCache.get(`${operatorId}-latest`)
|
const operatorSettings = settingsCache.get(`${operatorId}-latest`)
|
||||||
|
|
||||||
if (!!needsSettingsReload[operatorId] || !operatorSettings) {
|
if (needsSettingsReload[operatorId] || !operatorSettings) {
|
||||||
needsSettingsReload[operatorId]
|
needsSettingsReload[operatorId]
|
||||||
? logger.debug(
|
? logger.debug(
|
||||||
'Fetching and caching a new latest config value, as a reload was requested',
|
'Fetching and caching a new latest config value, as a reload was requested',
|
||||||
|
|
@ -128,8 +125,7 @@ const populateSettings = function (req, res, next) {
|
||||||
const versionId = settings.version
|
const versionId = settings.version
|
||||||
settingsCache.set(`${operatorId}-latest`, settings)
|
settingsCache.set(`${operatorId}-latest`, settings)
|
||||||
settingsCache.set(`${operatorId}-v${versionId}`, settings)
|
settingsCache.set(`${operatorId}-v${versionId}`, settings)
|
||||||
if (needsSettingsReload[operatorId])
|
delete needsSettingsReload[operatorId]
|
||||||
delete needsSettingsReload[operatorId]
|
|
||||||
req.settings = settings
|
req.settings = settings
|
||||||
})
|
})
|
||||||
.then(() => next())
|
.then(() => next())
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
const plugins = require('../plugins')
|
const { enqueueRecordPing } = require('../machine-loader')
|
||||||
|
|
||||||
module.exports = (req, res, next) =>
|
const record = (req, res, next) => {
|
||||||
plugins(req.settings, req.deviceId)
|
enqueueRecordPing({
|
||||||
.recordPing(req.deviceTime, req.query.version, req.query.model)
|
deviceId: req.deviceId,
|
||||||
.then(() => next())
|
last_online: req.deviceTime,
|
||||||
.catch(() => next())
|
model: req.query.model,
|
||||||
|
version: req.query.version,
|
||||||
|
})
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = record
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ const SETTINGS_CACHE_REFRESH = 3600
|
||||||
|
|
||||||
module.exports = (function () {
|
module.exports = (function () {
|
||||||
return {
|
return {
|
||||||
oldVersionId: 'unset',
|
|
||||||
needsSettingsReload: {},
|
needsSettingsReload: {},
|
||||||
settingsCache: new NodeCache({
|
settingsCache: new NodeCache({
|
||||||
stdTTL: SETTINGS_CACHE_REFRESH,
|
stdTTL: SETTINGS_CACHE_REFRESH,
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ function saveAccounts(accounts) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAccounts(schemaVersion) {
|
function _loadAccounts(db, schemaVersion) {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE type = $1
|
WHERE type = $1
|
||||||
|
|
@ -100,14 +100,15 @@ function loadAccounts(schemaVersion) {
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
|
|
||||||
return db
|
return db.oneOrNone(
|
||||||
.oneOrNone(sql, [
|
sql,
|
||||||
'accounts',
|
['accounts', schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION],
|
||||||
schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION,
|
row => row?.data?.accounts ?? {},
|
||||||
])
|
)
|
||||||
.then(_.compose(_.defaultTo({}), _.get('data.accounts')))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loadAccounts = schemaVersion => _loadAccounts(db, schemaVersion)
|
||||||
|
|
||||||
function hideSecretFields(accounts) {
|
function hideSecretFields(accounts) {
|
||||||
return _.flow(
|
return _.flow(
|
||||||
_.filter(path => !_.isEmpty(_.get(path, accounts))),
|
_.filter(path => !_.isEmpty(_.get(path, accounts))),
|
||||||
|
|
@ -167,16 +168,19 @@ function migrationSaveConfig(config) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLatest(schemaVersion) {
|
const loadLatest = schemaVersion =>
|
||||||
return Promise.all([
|
db
|
||||||
loadLatestConfigOrNoneReturningVersion(schemaVersion),
|
.task(t =>
|
||||||
loadAccounts(schemaVersion),
|
t.batch([
|
||||||
]).then(([configObj, accounts]) => ({
|
loadLatestConfigOrNoneReturningVersion(t, schemaVersion),
|
||||||
config: configObj.config,
|
_loadAccounts(t, schemaVersion),
|
||||||
accounts,
|
]),
|
||||||
version: configObj.version,
|
)
|
||||||
}))
|
.then(([configObj, accounts]) => ({
|
||||||
}
|
config: configObj.config,
|
||||||
|
accounts,
|
||||||
|
version: configObj.version,
|
||||||
|
}))
|
||||||
|
|
||||||
function loadLatestConfig() {
|
function loadLatestConfig() {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
|
|
@ -195,7 +199,7 @@ function loadLatestConfig() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLatestConfigOrNoneReturningVersion(schemaVersion) {
|
function loadLatestConfigOrNoneReturningVersion(db, schemaVersion) {
|
||||||
const sql = `SELECT data, id
|
const sql = `SELECT data, id
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE type = 'config'
|
WHERE type = 'config'
|
||||||
|
|
@ -222,7 +226,7 @@ function loadLatestConfigOrNone(schemaVersion) {
|
||||||
.then(row => (row ? row.data.config : {}))
|
.then(row => (row ? row.data.config : {}))
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadConfig(versionId) {
|
function loadConfig(db, versionId) {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
|
|
@ -231,8 +235,11 @@ function loadConfig(versionId) {
|
||||||
AND valid`
|
AND valid`
|
||||||
|
|
||||||
return db
|
return db
|
||||||
.one(sql, [versionId, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
.one(
|
||||||
.then(row => row.data.config)
|
sql,
|
||||||
|
[versionId, NEW_SETTINGS_LOADER_SCHEMA_VERSION],
|
||||||
|
({ data: { config } }) => config,
|
||||||
|
)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.name === 'QueryResultError') {
|
if (err.name === 'QueryResultError') {
|
||||||
throw new Error('No such config version: ' + versionId)
|
throw new Error('No such config version: ' + versionId)
|
||||||
|
|
@ -245,12 +252,14 @@ function loadConfig(versionId) {
|
||||||
function load(versionId) {
|
function load(versionId) {
|
||||||
if (!versionId) Promise.reject('versionId is required')
|
if (!versionId) Promise.reject('versionId is required')
|
||||||
|
|
||||||
return Promise.all([loadConfig(versionId), loadAccounts()]).then(
|
return db.task(t => {
|
||||||
([config, accounts]) => ({
|
t.batch([loadConfig(t, versionId), _loadAccounts(t)]).then(
|
||||||
config,
|
([config, accounts]) => ({
|
||||||
accounts,
|
config,
|
||||||
}),
|
accounts,
|
||||||
)
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchCurrentConfigVersion = () => {
|
const fetchCurrentConfigVersion = () => {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
const _ = require('lodash/fp')
|
|
||||||
|
|
||||||
function getOperatorId(service) {
|
function getOperatorId(service) {
|
||||||
const sql = `SELECT operator_id FROM operator_ids WHERE service = '${service}'`
|
const sql = 'SELECT operator_id FROM operator_ids WHERE service = ${service}'
|
||||||
return db.oneOrNone(sql).then(_.get('operator_id'))
|
return db.oneOrNone(sql, { service }, ({ operator_id }) => operator_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getOperatorId }
|
module.exports = { getOperatorId }
|
||||||
|
|
|
||||||
|
|
@ -81,13 +81,4 @@ function authorizeCaDownload(caToken) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPaired(deviceId) {
|
module.exports = { pair, unpair, authorizeCaDownload }
|
||||||
const sql =
|
|
||||||
'select device_id, name from devices where device_id=$1 and paired=TRUE'
|
|
||||||
|
|
||||||
return db
|
|
||||||
.oneOrNone(sql, [deviceId])
|
|
||||||
.then(row => (row && row.device_id === deviceId ? row.name : false))
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { pair, unpair, authorizeCaDownload, isPaired }
|
|
||||||
|
|
|
||||||
|
|
@ -409,31 +409,6 @@ function plugins(settings, deviceId) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function recordPing(deviceTime, version, model) {
|
|
||||||
const devices = {
|
|
||||||
version,
|
|
||||||
model,
|
|
||||||
last_online: deviceTime,
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.all([
|
|
||||||
db.none(
|
|
||||||
`insert into machine_pings(device_id, device_time)
|
|
||||||
values ($1, $2)
|
|
||||||
ON CONFLICT (device_id) DO UPDATE SET device_time = $2,
|
|
||||||
updated = now()`,
|
|
||||||
[deviceId, deviceTime],
|
|
||||||
),
|
|
||||||
db.none(
|
|
||||||
pgp.helpers.update(devices, null, 'devices') +
|
|
||||||
'WHERE device_id = ${deviceId}',
|
|
||||||
{
|
|
||||||
deviceId,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
function pruneMachinesHeartbeat() {
|
function pruneMachinesHeartbeat() {
|
||||||
const sql = `DELETE
|
const sql = `DELETE
|
||||||
FROM machine_network_heartbeat h
|
FROM machine_network_heartbeat h
|
||||||
|
|
@ -1062,7 +1037,6 @@ function plugins(settings, deviceId) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getRates,
|
getRates,
|
||||||
recordPing,
|
|
||||||
buildRates,
|
buildRates,
|
||||||
getRawRates,
|
getRawRates,
|
||||||
buildRatesNoCommission,
|
buildRatesNoCommission,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const coinAtmRadar = require('./coinatmradar/coinatmradar')
|
||||||
const configManager = require('./new-config-manager')
|
const configManager = require('./new-config-manager')
|
||||||
const complianceTriggers = require('./compliance-triggers')
|
const complianceTriggers = require('./compliance-triggers')
|
||||||
const settingsLoader = require('./new-settings-loader')
|
const settingsLoader = require('./new-settings-loader')
|
||||||
|
const machineLoader = require('./machine-loader')
|
||||||
const NodeCache = require('node-cache')
|
const NodeCache = require('node-cache')
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
const processBatches = require('./tx-batching-processing')
|
const processBatches = require('./tx-batching-processing')
|
||||||
|
|
@ -31,6 +32,7 @@ const PRUNE_MACHINES_HEARTBEAT = 1 * T.day
|
||||||
const TRANSACTION_BATCH_LIFECYCLE = 20 * T.minutes
|
const TRANSACTION_BATCH_LIFECYCLE = 20 * T.minutes
|
||||||
const TICKER_RATES_INTERVAL = 59 * T.seconds
|
const TICKER_RATES_INTERVAL = 59 * T.seconds
|
||||||
const FAILED_SCANS_INTERVAL = 1 * T.day
|
const FAILED_SCANS_INTERVAL = 1 * T.day
|
||||||
|
const PENDING_PINGS_INTERVAL = 90 * T.seconds // lib/notifier/codes.js
|
||||||
|
|
||||||
const CHECK_NOTIFICATION_INTERVAL = 20 * T.seconds
|
const CHECK_NOTIFICATION_INTERVAL = 20 * T.seconds
|
||||||
const PENDING_INTERVAL = 10 * T.seconds
|
const PENDING_INTERVAL = 10 * T.seconds
|
||||||
|
|
@ -309,6 +311,11 @@ function doPolling() {
|
||||||
QUEUE.SLOW,
|
QUEUE.SLOW,
|
||||||
settings,
|
settings,
|
||||||
)
|
)
|
||||||
|
addToQueue(
|
||||||
|
machineLoader.batchRecordPendingPings,
|
||||||
|
PENDING_PINGS_INTERVAL,
|
||||||
|
QUEUE.SLOW,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { setup, reload }
|
module.exports = { setup, reload }
|
||||||
|
|
|
||||||
|
|
@ -78,11 +78,11 @@ const loadRoutes = async () => {
|
||||||
// app /pair and /ca routes
|
// app /pair and /ca routes
|
||||||
app.use('/', pairingRoutes)
|
app.use('/', pairingRoutes)
|
||||||
|
|
||||||
app.use(findOperatorId)
|
|
||||||
app.use(populateDeviceId)
|
app.use(populateDeviceId)
|
||||||
app.use(authorize)
|
app.use(authorize)
|
||||||
app.use(configRequiredRoutes, populateSettings)
|
|
||||||
app.use(filterOldRequests)
|
app.use(filterOldRequests)
|
||||||
|
app.use(findOperatorId)
|
||||||
|
app.use(configRequiredRoutes, populateSettings)
|
||||||
|
|
||||||
// other app routes
|
// other app routes
|
||||||
app.use('/graphql', recordPing)
|
app.use('/graphql', recordPing)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function getLastSeen(req, res, next) {
|
||||||
function updateLogs(req, res, next) {
|
function updateLogs(req, res, next) {
|
||||||
return logs
|
return logs
|
||||||
.update(req.deviceId, req.body.logs)
|
.update(req.deviceId, req.body.logs)
|
||||||
.then(status => res.json({ success: status }))
|
.then(success => res.json({ success }))
|
||||||
.catch(next)
|
.catch(next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,31 +3,31 @@ const db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sqls = [
|
var sqls = [
|
||||||
'CREATE TABLE IF NOT EXISTS user_config ( ' +
|
'CREATE TABLE IF NOT EXISTS user_config ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'type text NOT NULL, ' +
|
'type text NOT NULL, ' +
|
||||||
'data json NOT NULL ' +
|
'data json NOT NULL ' +
|
||||||
')',
|
')',
|
||||||
|
|
||||||
'CREATE TABLE IF NOT EXISTS devices ( ' +
|
'CREATE TABLE IF NOT EXISTS devices ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'fingerprint text NOT NULL UNIQUE, ' +
|
'fingerprint text NOT NULL UNIQUE, ' +
|
||||||
'name text, ' +
|
'name text, ' +
|
||||||
'authorized boolean, ' +
|
'authorized boolean, ' +
|
||||||
'unpair boolean NOT NULL DEFAULT false' +
|
'unpair boolean NOT NULL DEFAULT false' +
|
||||||
')',
|
')',
|
||||||
|
|
||||||
'CREATE TABLE IF NOT EXISTS pairing_tokens (' +
|
'CREATE TABLE IF NOT EXISTS pairing_tokens (' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'token text, ' +
|
'token text, ' +
|
||||||
'created timestamp NOT NULL DEFAULT now() ' +
|
'created timestamp NOT NULL DEFAULT now() ' +
|
||||||
')',
|
')',
|
||||||
|
|
||||||
'CREATE TABLE IF NOT EXISTS users ( ' +
|
'CREATE TABLE IF NOT EXISTS users ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'userName text NOT NULL UNIQUE, ' +
|
'userName text NOT NULL UNIQUE, ' +
|
||||||
'salt text NOT NULL, ' +
|
'salt text NOT NULL, ' +
|
||||||
'pwdHash text NOT NULL ' +
|
'pwdHash text NOT NULL ' +
|
||||||
')'
|
')',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sqls, next)
|
db.multi(sqls, next)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
['CREATE TABLE bills ( ' +
|
'CREATE TABLE bills ( ' +
|
||||||
'id uuid PRIMARY KEY, ' +
|
'id uuid PRIMARY KEY, ' +
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'denomination integer NOT NULL, ' +
|
'denomination integer NOT NULL, ' +
|
||||||
'currency_code text NOT NULL, ' +
|
'currency_code text NOT NULL, ' +
|
||||||
'satoshis integer NOT NULL, ' +
|
'satoshis integer NOT NULL, ' +
|
||||||
'to_address text NOT NULL, ' +
|
'to_address text NOT NULL, ' +
|
||||||
'session_id uuid NOT NULL, ' +
|
'session_id uuid NOT NULL, ' +
|
||||||
'device_time bigint NOT NULL, ' +
|
'device_time bigint NOT NULL, ' +
|
||||||
'created timestamp NOT NULL DEFAULT now() )']
|
'created timestamp NOT NULL DEFAULT now() )',
|
||||||
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
db.multi(['CREATE TABLE IF NOT EXISTS machine_events ( ' +
|
db.multi(
|
||||||
'id uuid PRIMARY KEY, ' +
|
[
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'CREATE TABLE IF NOT EXISTS machine_events ( ' +
|
||||||
'event_type text NOT NULL, ' +
|
'id uuid PRIMARY KEY, ' +
|
||||||
'note text, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'device_time bigint NOT NULL, ' +
|
'event_type text NOT NULL, ' +
|
||||||
'created timestamp NOT NULL DEFAULT now() )'], next)
|
'note text, ' +
|
||||||
|
'device_time bigint NOT NULL, ' +
|
||||||
|
'created timestamp NOT NULL DEFAULT now() )',
|
||||||
|
],
|
||||||
|
next,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.down = function (next) {
|
exports.down = function (next) {
|
||||||
|
|
|
||||||
|
|
@ -1,64 +1,83 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
function singleQuotify (item) { return '\'' + item + '\'' }
|
function singleQuotify(item) {
|
||||||
|
return "'" + item + "'"
|
||||||
|
}
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var stages = ['initial_request', 'partial_request', 'final_request',
|
var stages = [
|
||||||
'partial_send', 'deposit', 'dispense_request', 'dispense']
|
'initial_request',
|
||||||
.map(singleQuotify).join(',')
|
'partial_request',
|
||||||
|
'final_request',
|
||||||
|
'partial_send',
|
||||||
|
'deposit',
|
||||||
|
'dispense_request',
|
||||||
|
'dispense',
|
||||||
|
]
|
||||||
|
.map(singleQuotify)
|
||||||
|
.join(',')
|
||||||
|
|
||||||
var authorizations = ['timeout', 'machine', 'pending', 'rejected',
|
var authorizations = [
|
||||||
'published', 'authorized', 'confirmed'].map(singleQuotify).join(',')
|
'timeout',
|
||||||
|
'machine',
|
||||||
|
'pending',
|
||||||
|
'rejected',
|
||||||
|
'published',
|
||||||
|
'authorized',
|
||||||
|
'confirmed',
|
||||||
|
]
|
||||||
|
.map(singleQuotify)
|
||||||
|
.join(',')
|
||||||
|
|
||||||
var sqls = [
|
var sqls = [
|
||||||
'CREATE TYPE transaction_stage AS ENUM (' + stages + ')',
|
'CREATE TYPE transaction_stage AS ENUM (' + stages + ')',
|
||||||
'CREATE TYPE transaction_authority AS ENUM (' + authorizations + ')',
|
'CREATE TYPE transaction_authority AS ENUM (' + authorizations + ')',
|
||||||
|
|
||||||
'CREATE TABLE transactions ( ' +
|
'CREATE TABLE transactions ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'session_id uuid NOT NULL, ' +
|
'session_id uuid NOT NULL, ' +
|
||||||
'device_fingerprint text, ' +
|
'device_fingerprint text, ' +
|
||||||
'to_address text NOT NULL, ' +
|
'to_address text NOT NULL, ' +
|
||||||
'satoshis integer NOT NULL DEFAULT 0, ' +
|
'satoshis integer NOT NULL DEFAULT 0, ' +
|
||||||
'fiat integer NOT NULL DEFAULT 0, ' +
|
'fiat integer NOT NULL DEFAULT 0, ' +
|
||||||
'currency_code text NOT NULL, ' +
|
'currency_code text NOT NULL, ' +
|
||||||
'fee integer NOT NULL DEFAULT 0, ' +
|
'fee integer NOT NULL DEFAULT 0, ' +
|
||||||
'incoming boolean NOT NULL, ' +
|
'incoming boolean NOT NULL, ' +
|
||||||
'stage transaction_stage NOT NULL, ' +
|
'stage transaction_stage NOT NULL, ' +
|
||||||
'authority transaction_authority NOT NULL, ' +
|
'authority transaction_authority NOT NULL, ' +
|
||||||
'tx_hash text, ' +
|
'tx_hash text, ' +
|
||||||
'error text, ' +
|
'error text, ' +
|
||||||
'created timestamp NOT NULL DEFAULT now(), ' +
|
'created timestamp NOT NULL DEFAULT now(), ' +
|
||||||
'UNIQUE (session_id, to_address, stage, authority) ' +
|
'UNIQUE (session_id, to_address, stage, authority) ' +
|
||||||
')',
|
')',
|
||||||
'CREATE INDEX ON transactions (session_id)',
|
'CREATE INDEX ON transactions (session_id)',
|
||||||
|
|
||||||
'CREATE TABLE pending_transactions ( ' +
|
'CREATE TABLE pending_transactions ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'session_id uuid UNIQUE NOT NULL, ' +
|
'session_id uuid UNIQUE NOT NULL, ' +
|
||||||
'incoming boolean NOT NULL, ' +
|
'incoming boolean NOT NULL, ' +
|
||||||
'currency_code text NOT NULL, ' +
|
'currency_code text NOT NULL, ' +
|
||||||
'to_address text NOT NULL, ' +
|
'to_address text NOT NULL, ' +
|
||||||
'satoshis integer NOT NULL, ' +
|
'satoshis integer NOT NULL, ' +
|
||||||
'updated timestamp NOT NULL DEFAULT now() ' +
|
'updated timestamp NOT NULL DEFAULT now() ' +
|
||||||
')',
|
')',
|
||||||
|
|
||||||
'CREATE TABLE dispenses ( ' +
|
'CREATE TABLE dispenses ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'transaction_id integer UNIQUE REFERENCES transactions(id), ' +
|
'transaction_id integer UNIQUE REFERENCES transactions(id), ' +
|
||||||
'dispense1 integer NOT NULL, ' +
|
'dispense1 integer NOT NULL, ' +
|
||||||
'reject1 integer NOT NULL, ' +
|
'reject1 integer NOT NULL, ' +
|
||||||
'count1 integer NOT NULL, ' +
|
'count1 integer NOT NULL, ' +
|
||||||
'dispense2 integer NOT NULL, ' +
|
'dispense2 integer NOT NULL, ' +
|
||||||
'reject2 integer NOT NULL, ' +
|
'reject2 integer NOT NULL, ' +
|
||||||
'count2 integer NOT NULL, ' +
|
'count2 integer NOT NULL, ' +
|
||||||
'refill boolean NOT NULL, ' +
|
'refill boolean NOT NULL, ' +
|
||||||
'error text, ' +
|
'error text, ' +
|
||||||
'created timestamp NOT NULL DEFAULT now() ' +
|
'created timestamp NOT NULL DEFAULT now() ' +
|
||||||
')',
|
')',
|
||||||
'CREATE INDEX ON dispenses (device_fingerprint)'
|
'CREATE INDEX ON dispenses (device_fingerprint)',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sqls, next)
|
db.multi(sqls, next)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ exports.up = function (next) {
|
||||||
"alter table pending_transactions add crypto_code text default 'BTC'",
|
"alter table pending_transactions add crypto_code text default 'BTC'",
|
||||||
'alter table pending_transactions alter satoshis TYPE bigint',
|
'alter table pending_transactions alter satoshis TYPE bigint',
|
||||||
"alter table bills add crypto_code text default 'BTC'",
|
"alter table bills add crypto_code text default 'BTC'",
|
||||||
'alter table bills alter satoshis TYPE bigint'
|
'alter table bills alter satoshis TYPE bigint',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sqls, next)
|
db.multi(sqls, next)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,15 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
db.multi(['CREATE TABLE IF NOT EXISTS machine_configs ( ' +
|
db.multi(
|
||||||
'id serial PRIMARY KEY, ' +
|
[
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'CREATE TABLE IF NOT EXISTS machine_configs ( ' +
|
||||||
'data json NOT NULL )'], next)
|
'id serial PRIMARY KEY, ' +
|
||||||
|
'device_fingerprint text NOT NULL, ' +
|
||||||
|
'data json NOT NULL )',
|
||||||
|
],
|
||||||
|
next,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.down = function (next) {
|
exports.down = function (next) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table transactions add phone text',
|
'alter table transactions add phone text',
|
||||||
'create index on transactions (phone)'
|
'create index on transactions (phone)',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,21 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
function singleQuotify (item) { return '\'' + item + '\'' }
|
function singleQuotify(item) {
|
||||||
|
return "'" + item + "'"
|
||||||
|
}
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var statuses = ['notSeen', 'published', 'authorized', 'instant',
|
var statuses = [
|
||||||
'confirmed', 'rejected', 'insufficientFunds']
|
'notSeen',
|
||||||
.map(singleQuotify).join(',')
|
'published',
|
||||||
|
'authorized',
|
||||||
|
'instant',
|
||||||
|
'confirmed',
|
||||||
|
'rejected',
|
||||||
|
'insufficientFunds',
|
||||||
|
]
|
||||||
|
.map(singleQuotify)
|
||||||
|
.join(',')
|
||||||
|
|
||||||
var sql = [
|
var sql = [
|
||||||
'create type status_stage AS enum (' + statuses + ')',
|
'create type status_stage AS enum (' + statuses + ')',
|
||||||
|
|
@ -13,7 +23,7 @@ exports.up = function (next) {
|
||||||
'alter table transactions add notified boolean NOT NULL DEFAULT false',
|
'alter table transactions add notified boolean NOT NULL DEFAULT false',
|
||||||
'alter table transactions add redeem boolean NOT NULL DEFAULT false',
|
'alter table transactions add redeem boolean NOT NULL DEFAULT false',
|
||||||
'alter table transactions add confirmation_time timestamptz',
|
'alter table transactions add confirmation_time timestamptz',
|
||||||
'alter table transactions add status status_stage NOT NULL DEFAULT \'notSeen\''
|
"alter table transactions add status status_stage NOT NULL DEFAULT 'notSeen'",
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ exports.up = function (next) {
|
||||||
'alter table dispenses alter created type timestamptz',
|
'alter table dispenses alter created type timestamptz',
|
||||||
'alter table machine_events alter created type timestamptz',
|
'alter table machine_events alter created type timestamptz',
|
||||||
'alter table pairing_tokens alter created type timestamptz',
|
'alter table pairing_tokens alter created type timestamptz',
|
||||||
'alter table pending_transactions alter updated type timestamptz'
|
'alter table pending_transactions alter updated type timestamptz',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,21 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
db.multi(['CREATE TABLE IF NOT EXISTS cached_responses ( ' +
|
db.multi(
|
||||||
'id serial PRIMARY KEY, ' +
|
[
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'CREATE TABLE IF NOT EXISTS cached_responses ( ' +
|
||||||
'session_id uuid NOT NULL, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'path text NOT NULL, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'method text NOT NULL, ' +
|
'session_id uuid NOT NULL, ' +
|
||||||
'body json NOT NULL, ' +
|
'path text NOT NULL, ' +
|
||||||
'created timestamptz NOT NULL DEFAULT now(), ' +
|
'method text NOT NULL, ' +
|
||||||
'UNIQUE (device_fingerprint, session_id, path, method) ' +
|
'body json NOT NULL, ' +
|
||||||
')'], next)
|
'created timestamptz NOT NULL DEFAULT now(), ' +
|
||||||
|
'UNIQUE (device_fingerprint, session_id, path, method) ' +
|
||||||
|
')',
|
||||||
|
],
|
||||||
|
next,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.down = function (next) {
|
exports.down = function (next) {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,25 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
function singleQuotify (item) { return '\'' + item + '\'' }
|
function singleQuotify(item) {
|
||||||
|
return "'" + item + "'"
|
||||||
|
}
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var actions = ['published', 'authorized', 'instant', 'confirmed', 'rejected',
|
var actions = [
|
||||||
'insufficientFunds', 'dispenseRequested', 'dispensed', 'notified',
|
'published',
|
||||||
'addedPhone', 'redeem']
|
'authorized',
|
||||||
.map(singleQuotify).join(',')
|
'instant',
|
||||||
|
'confirmed',
|
||||||
|
'rejected',
|
||||||
|
'insufficientFunds',
|
||||||
|
'dispenseRequested',
|
||||||
|
'dispensed',
|
||||||
|
'notified',
|
||||||
|
'addedPhone',
|
||||||
|
'redeem',
|
||||||
|
]
|
||||||
|
.map(singleQuotify)
|
||||||
|
.join(',')
|
||||||
|
|
||||||
var sql = [
|
var sql = [
|
||||||
`create table cash_in_txs (
|
`create table cash_in_txs (
|
||||||
|
|
@ -32,7 +45,7 @@ exports.up = function (next) {
|
||||||
fiat numeric(14, 5) NOT NULL,
|
fiat numeric(14, 5) NOT NULL,
|
||||||
currency_code text NOT NULL,
|
currency_code text NOT NULL,
|
||||||
tx_hash text,
|
tx_hash text,
|
||||||
status status_stage NOT NULL default \'notSeen\',
|
status status_stage NOT NULL default 'notSeen',
|
||||||
dispensed boolean NOT NULL default false,
|
dispensed boolean NOT NULL default false,
|
||||||
notified boolean NOT NULL default false,
|
notified boolean NOT NULL default false,
|
||||||
redeem boolean NOT NULL default false,
|
redeem boolean NOT NULL default false,
|
||||||
|
|
@ -49,7 +62,7 @@ exports.up = function (next) {
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`,
|
)`,
|
||||||
`alter table dispenses add session_id uuid`,
|
`alter table dispenses add session_id uuid`,
|
||||||
`alter table dispenses drop constraint dispenses_transaction_id_fkey`
|
`alter table dispenses drop constraint dispenses_transaction_id_fkey`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ exports.up = function (next) {
|
||||||
swept boolean NOT NULL default false,
|
swept boolean NOT NULL default false,
|
||||||
created timestamptz NOT NULL default now(),
|
created timestamptz NOT NULL default now(),
|
||||||
unique (crypto_code, hd_serial)
|
unique (crypto_code, hd_serial)
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table cash_out_hds add last_checked timestamptz not null default now()',
|
'alter table cash_out_hds add last_checked timestamptz not null default now()',
|
||||||
'alter table cash_out_hds add confirmed boolean not null default false',
|
'alter table cash_out_hds add confirmed boolean not null default false',
|
||||||
'create index on cash_out_hds (confirmed, last_checked)'
|
'create index on cash_out_hds (confirmed, last_checked)',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ exports.up = function (next) {
|
||||||
|
|
||||||
'alter table machine_configs rename device_fingerprint to device_id',
|
'alter table machine_configs rename device_fingerprint to device_id',
|
||||||
|
|
||||||
'alter table machine_events rename device_fingerprint to device_id'
|
'alter table machine_events rename device_fingerprint to device_id',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ exports.up = function (next) {
|
||||||
`create table paired_devices (
|
`create table paired_devices (
|
||||||
device_id text PRIMARY KEY,
|
device_id text PRIMARY KEY,
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ exports.up = function (next) {
|
||||||
status integer NOT NULL,
|
status integer NOT NULL,
|
||||||
pending boolean NOT NULL,
|
pending boolean NOT NULL,
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ exports.up = function (next) {
|
||||||
token text PRIMARY KEY,
|
token text PRIMARY KEY,
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ exports.up = function (next) {
|
||||||
display boolean NOT NULL default TRUE,
|
display boolean NOT NULL default TRUE,
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`,
|
)`,
|
||||||
'alter table pairing_tokens add column name text NOT NULL'
|
'alter table pairing_tokens add column name text NOT NULL',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table dispenses drop column count1',
|
'alter table dispenses drop column count1',
|
||||||
'alter table dispenses drop column count2',
|
'alter table dispenses drop column count2',
|
||||||
'alter table dispenses drop column refill'
|
'alter table dispenses drop column refill',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ exports.up = function (next) {
|
||||||
event_type text NOT NULL,
|
event_type text NOT NULL,
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`,
|
)`,
|
||||||
'CREATE INDEX ON server_events (created)'
|
'CREATE INDEX ON server_events (created)',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ exports.up = function (next) {
|
||||||
'alter table user_config add column created timestamptz NOT NULL default now()',
|
'alter table user_config add column created timestamptz NOT NULL default now()',
|
||||||
`ALTER TABLE devices ADD CONSTRAINT user_config_id
|
`ALTER TABLE devices ADD CONSTRAINT user_config_id
|
||||||
FOREIGN KEY (user_config_id)
|
FOREIGN KEY (user_config_id)
|
||||||
REFERENCES user_config (id)`
|
REFERENCES user_config (id)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ exports.up = function (next) {
|
||||||
'alter table bills rename denomination to fiat',
|
'alter table bills rename denomination to fiat',
|
||||||
'alter table bills drop column to_address',
|
'alter table bills drop column to_address',
|
||||||
'alter table bills drop column device_id',
|
'alter table bills drop column device_id',
|
||||||
'alter table cash_out_txs rename currency_code to fiat_code'
|
'alter table cash_out_txs rename currency_code to fiat_code',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ exports.up = function (next) {
|
||||||
'alter table cash_out_txs add column denomination_2 integer',
|
'alter table cash_out_txs add column denomination_2 integer',
|
||||||
'alter table cash_out_txs add column dispense_error text',
|
'alter table cash_out_txs add column dispense_error text',
|
||||||
'alter table cash_out_txs add column dispense_time timestamptz',
|
'alter table cash_out_txs add column dispense_time timestamptz',
|
||||||
'drop table dispenses'
|
'drop table dispenses',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ exports.up = function (next) {
|
||||||
'drop table transactions',
|
'drop table transactions',
|
||||||
'drop table idempotents',
|
'drop table idempotents',
|
||||||
'drop table machine_configs',
|
'drop table machine_configs',
|
||||||
'drop table pending_transactions'
|
'drop table pending_transactions',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ exports.up = function (next) {
|
||||||
crypto_atoms bigint not null,
|
crypto_atoms bigint not null,
|
||||||
fiat_code text not null,
|
fiat_code text not null,
|
||||||
created timestamptz NOT NULL default now()
|
created timestamptz NOT NULL default now()
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ exports.up = function (next) {
|
||||||
'alter table cash_in_txs add column operator_completed boolean not null default false',
|
'alter table cash_in_txs add column operator_completed boolean not null default false',
|
||||||
'alter table cash_in_txs add column send_pending boolean not null default false',
|
'alter table cash_in_txs add column send_pending boolean not null default false',
|
||||||
'alter table cash_out_txs add column device_time bigint not null',
|
'alter table cash_out_txs add column device_time bigint not null',
|
||||||
'alter table cash_out_txs add column timedout boolean not null default false'
|
'alter table cash_out_txs add column timedout boolean not null default false',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ exports.up = function (next) {
|
||||||
error_code text,
|
error_code text,
|
||||||
tx_hash text,
|
tx_hash text,
|
||||||
created timestamptz not null default now()
|
created timestamptz not null default now()
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ exports.up = function (next) {
|
||||||
'alter table cash_out_txs drop column dispense_error',
|
'alter table cash_out_txs drop column dispense_error',
|
||||||
'alter table cash_out_txs drop column dispense_time',
|
'alter table cash_out_txs drop column dispense_time',
|
||||||
'alter table cash_out_txs add column dispense_confirmed boolean default false',
|
'alter table cash_out_txs add column dispense_confirmed boolean default false',
|
||||||
'alter table cash_out_txs rename column dispensed to dispense'
|
'alter table cash_out_txs rename column dispensed to dispense',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['alter table user_config add column valid boolean not null']
|
||||||
'alter table user_config add column valid boolean not null'
|
|
||||||
]
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ exports.up = function (next) {
|
||||||
'alter table cash_out_txs add column provisioned_1 integer',
|
'alter table cash_out_txs add column provisioned_1 integer',
|
||||||
'alter table cash_out_txs add column provisioned_2 integer',
|
'alter table cash_out_txs add column provisioned_2 integer',
|
||||||
'alter table cash_out_txs add column denomination_1 integer',
|
'alter table cash_out_txs add column denomination_1 integer',
|
||||||
'alter table cash_out_txs add column denomination_2 integer'
|
'alter table cash_out_txs add column denomination_2 integer',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = ['alter table devices drop column name']
|
||||||
'alter table devices drop column name'
|
|
||||||
]
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ exports.up = function (next) {
|
||||||
lag_median_ms integer not null,
|
lag_median_ms integer not null,
|
||||||
day date not null)`,
|
day date not null)`,
|
||||||
'alter table machine_events drop column device_time',
|
'alter table machine_events drop column device_time',
|
||||||
'alter table machine_events add column device_time timestamptz'
|
'alter table machine_events add column device_time timestamptz',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ exports.up = function (next) {
|
||||||
'alter table cash_in_txs add column minimum_tx integer not null',
|
'alter table cash_in_txs add column minimum_tx integer not null',
|
||||||
'alter table bills add column cash_in_fee numeric(14, 5) not null',
|
'alter table bills add column cash_in_fee numeric(14, 5) not null',
|
||||||
'alter table bills add column cash_in_fee_crypto bigint not null',
|
'alter table bills add column cash_in_fee_crypto bigint not null',
|
||||||
'alter table bills add column crypto_atoms_after_fee bigint not null'
|
'alter table bills add column crypto_atoms_after_fee bigint not null',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['alter table cash_out_txs add column error_code text']
|
||||||
'alter table cash_out_txs add column error_code text'
|
|
||||||
]
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ exports.up = function (next) {
|
||||||
device_id text not null,
|
device_id text not null,
|
||||||
user_id integer not null,
|
user_id integer not null,
|
||||||
cash_box_count integer not null,
|
cash_box_count integer not null,
|
||||||
created timestamptz not null default now())`
|
created timestamptz not null default now())`,
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ var db = require('./db')
|
||||||
var anonymous = require('../lib/constants').anonymousCustomer
|
var anonymous = require('../lib/constants').anonymousCustomer
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[`create table customers (
|
`create table customers (
|
||||||
id uuid PRIMARY KEY,
|
id uuid PRIMARY KEY,
|
||||||
phone text unique,
|
phone text unique,
|
||||||
phone_at timestamptz,
|
phone_at timestamptz,
|
||||||
|
|
@ -22,8 +22,8 @@ exports.up = function (next) {
|
||||||
created timestamptz NOT NULL DEFAULT now() )`,
|
created timestamptz NOT NULL DEFAULT now() )`,
|
||||||
`insert into customers (id, name) VALUES ( '${anonymous.uuid}','${anonymous.name}' )`,
|
`insert into customers (id, name) VALUES ( '${anonymous.uuid}','${anonymous.name}' )`,
|
||||||
`alter table cash_in_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`,
|
`alter table cash_in_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`,
|
||||||
`alter table cash_out_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`
|
`alter table cash_out_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[ "create type compliance_types as enum ('manual', 'sanctions', 'sanctions_override')",
|
"create type compliance_types as enum ('manual', 'sanctions', 'sanctions_override')",
|
||||||
`create table compliance_authorizations (
|
`create table compliance_authorizations (
|
||||||
id uuid PRIMARY KEY,
|
id uuid PRIMARY KEY,
|
||||||
customer_id uuid REFERENCES customers (id),
|
customer_id uuid REFERENCES customers (id),
|
||||||
compliance_type compliance_types NOT NULL,
|
compliance_type compliance_types NOT NULL,
|
||||||
authorized_at timestamptz NOT NULL,
|
authorized_at timestamptz NOT NULL,
|
||||||
authorized_by text REFERENCES user_tokens (token) )` ]
|
authorized_by text REFERENCES user_tokens (token) )`,
|
||||||
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = [
|
||||||
'alter table cash_in_txs drop column device_time',
|
'alter table cash_in_txs drop column device_time',
|
||||||
'alter table cash_out_txs drop column device_time'
|
'alter table cash_out_txs drop column device_time',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = [
|
||||||
'alter table cash_in_txs add column tx_version integer not null',
|
'alter table cash_in_txs add column tx_version integer not null',
|
||||||
'alter table cash_out_txs add column tx_version integer not null'
|
'alter table cash_out_txs add column tx_version integer not null',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = [
|
||||||
'alter table cash_out_txs add column published_at timestamptz',
|
'alter table cash_out_txs add column published_at timestamptz',
|
||||||
'alter table cash_out_txs rename column confirmation_time to confirmed_at'
|
'alter table cash_out_txs rename column confirmation_time to confirmed_at',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ exports.up = function (next) {
|
||||||
'alter table compliance_authorizations rename to compliance_overrides',
|
'alter table compliance_authorizations rename to compliance_overrides',
|
||||||
'alter table compliance_overrides add column verification verification_type not null',
|
'alter table compliance_overrides add column verification verification_type not null',
|
||||||
'alter table compliance_overrides rename column authorized_at to override_at',
|
'alter table compliance_overrides rename column authorized_at to override_at',
|
||||||
'alter table compliance_overrides rename column authorized_by to override_by'
|
'alter table compliance_overrides rename column authorized_by to override_by',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ exports.up = function (next) {
|
||||||
`create type compliance_type as enum
|
`create type compliance_type as enum
|
||||||
('authorized', 'sms', 'id_card_data', 'id_card_photo', 'sanctions', 'front_camera', 'hard_limit')`,
|
('authorized', 'sms', 'id_card_data', 'id_card_photo', 'sanctions', 'front_camera', 'hard_limit')`,
|
||||||
'alter table compliance_overrides alter column compliance_type set data type compliance_type using compliance_type::text::compliance_type',
|
'alter table compliance_overrides alter column compliance_type set data type compliance_type using compliance_type::text::compliance_type',
|
||||||
'drop type old_compliance_type'
|
'drop type old_compliance_type',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[`create table logs (
|
`create table logs (
|
||||||
id uuid PRIMARY KEY,
|
id uuid PRIMARY KEY,
|
||||||
device_id text,
|
device_id text,
|
||||||
log_level text,
|
log_level text,
|
||||||
timestamp timestamptz,
|
timestamp timestamptz,
|
||||||
message text)`
|
message text)`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[`create table support_logs (
|
`create table support_logs (
|
||||||
id uuid PRIMARY KEY,
|
id uuid PRIMARY KEY,
|
||||||
device_id text,
|
device_id text,
|
||||||
timestamp timestamptz not null default now() )`,
|
timestamp timestamptz not null default now() )`,
|
||||||
'alter table logs add column server_timestamp timestamptz not null default now() '
|
'alter table logs add column server_timestamp timestamptz not null default now() ',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = [
|
||||||
'alter table devices add column name text',
|
'alter table devices add column name text',
|
||||||
'alter table devices alter column name set not null'
|
'alter table devices alter column name set not null',
|
||||||
]
|
]
|
||||||
|
|
||||||
return db.multi(sql, next)
|
return db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[`create table sanctions_logs (
|
`create table sanctions_logs (
|
||||||
id uuid PRIMARY KEY,
|
id uuid PRIMARY KEY,
|
||||||
device_id text not null,
|
device_id text not null,
|
||||||
sanctioned_id text not null,
|
sanctioned_id text not null,
|
||||||
sanctioned_alias_id text,
|
sanctioned_alias_id text,
|
||||||
sanctioned_alias_full_name text not null,
|
sanctioned_alias_full_name text not null,
|
||||||
customer_id uuid not null references customers,
|
customer_id uuid not null references customers,
|
||||||
created timestamptz not null default now() )`
|
created timestamptz not null default now() )`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ exports.up = function (next) {
|
||||||
'alter table trades alter column crypto_atoms type numeric(30)',
|
'alter table trades alter column crypto_atoms type numeric(30)',
|
||||||
'alter table bills alter column crypto_atoms type numeric(30)',
|
'alter table bills alter column crypto_atoms type numeric(30)',
|
||||||
'alter table bills alter column cash_in_fee_crypto type numeric(30)',
|
'alter table bills alter column cash_in_fee_crypto type numeric(30)',
|
||||||
'alter table bills alter column crypto_atoms_after_fee type numeric(30)'
|
'alter table bills alter column crypto_atoms_after_fee type numeric(30)',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table devices add column last_online timestamptz not null default now()',
|
'alter table devices add column last_online timestamptz not null default now()',
|
||||||
"alter table devices add column location json not null default '{}'"
|
"alter table devices add column location json not null default '{}'",
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = [
|
||||||
'alter table cash_in_txs add column terms_accepted boolean not null default false',
|
'alter table cash_in_txs add column terms_accepted boolean not null default false',
|
||||||
'alter table cash_out_txs add column terms_accepted boolean not null default false'
|
'alter table cash_out_txs add column terms_accepted boolean not null default false',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table cash_out_txs add column layer_2_address text null',
|
'alter table cash_out_txs add column layer_2_address text null',
|
||||||
'alter table cash_out_actions add column layer_2_address text null'
|
'alter table cash_out_actions add column layer_2_address text null',
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
"alter table cash_out_actions add device_id text not null default ''"
|
"alter table cash_out_actions add device_id text not null default ''",
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
|
||||||
exports.up = function(next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'TRUNCATE TABLE machine_pings',
|
'TRUNCATE TABLE machine_pings',
|
||||||
'ALTER TABLE machine_pings DROP id',
|
'ALTER TABLE machine_pings DROP id',
|
||||||
'ALTER TABLE machine_pings DROP serial_number',
|
'ALTER TABLE machine_pings DROP serial_number',
|
||||||
'ALTER TABLE machine_pings ADD CONSTRAINT PK_device_id PRIMARY KEY (device_id)',
|
'ALTER TABLE machine_pings ADD CONSTRAINT PK_device_id PRIMARY KEY (device_id)',
|
||||||
'ALTER TABLE machine_pings ADD CONSTRAINT U_device_id UNIQUE(device_id)'
|
'ALTER TABLE machine_pings ADD CONSTRAINT U_device_id UNIQUE(device_id)',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.down = function(next) {
|
exports.down = function (next) {
|
||||||
next();
|
next()
|
||||||
};
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = ['alter table trades add column error text']
|
||||||
'alter table trades add column error text',
|
|
||||||
]
|
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'ALTER TABLE cash_in_txs ADD COLUMN commission_percentage numeric(14, 5) null DEFAULT null',
|
'ALTER TABLE cash_in_txs ADD COLUMN commission_percentage numeric(14, 5) null DEFAULT null',
|
||||||
'ALTER TABLE cash_out_txs ADD COLUMN commission_percentage numeric(14, 5) null DEFAULT null'
|
'ALTER TABLE cash_out_txs ADD COLUMN commission_percentage numeric(14, 5) null DEFAULT null',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'ALTER TABLE cash_in_txs ADD COLUMN raw_ticker_price numeric(14, 5) null DEFAULT null',
|
'ALTER TABLE cash_in_txs ADD COLUMN raw_ticker_price numeric(14, 5) null DEFAULT null',
|
||||||
'ALTER TABLE cash_out_txs ADD COLUMN raw_ticker_price numeric(14, 5) null DEFAULT null'
|
'ALTER TABLE cash_out_txs ADD COLUMN raw_ticker_price numeric(14, 5) null DEFAULT null',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['TRUNCATE TABLE server_events']
|
||||||
'TRUNCATE TABLE server_events'
|
|
||||||
]
|
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[`create table blacklist (
|
`create table blacklist (
|
||||||
crypto_code text not null,
|
crypto_code text not null,
|
||||||
address text not null,
|
address text not null,
|
||||||
unique (crypto_code, address)
|
unique (crypto_code, address)
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['ALTER TABLE machine_pings RENAME COLUMN created to updated']
|
||||||
'ALTER TABLE machine_pings RENAME COLUMN created to updated'
|
|
||||||
]
|
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
"ALTER TABLE blacklist ADD COLUMN created_by_operator boolean not null default 't' "
|
"ALTER TABLE blacklist ADD COLUMN created_by_operator boolean not null default 't' ",
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[
|
'create table server_logs ( ' +
|
||||||
'create table server_logs ( ' +
|
|
||||||
'id uuid PRIMARY KEY, ' +
|
'id uuid PRIMARY KEY, ' +
|
||||||
'device_id text, ' +
|
'device_id text, ' +
|
||||||
'log_level text, ' +
|
'log_level text, ' +
|
||||||
|
|
@ -11,10 +10,10 @@ exports.up = function (next) {
|
||||||
'message text, ' +
|
'message text, ' +
|
||||||
'meta json)',
|
'meta json)',
|
||||||
|
|
||||||
`create table server_support_logs (
|
`create table server_support_logs (
|
||||||
id uuid PRIMARY KEY,
|
id uuid PRIMARY KEY,
|
||||||
timestamp timestamptz not null default now() )`
|
timestamp timestamptz not null default now() )`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'ALTER TABLE cash_out_txs ADD COLUMN received_crypto_atoms numeric(30) null DEFAULT null'
|
'ALTER TABLE cash_out_txs ADD COLUMN received_crypto_atoms numeric(30) null DEFAULT null',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table devices add column version text',
|
'alter table devices add column version text',
|
||||||
'alter table devices add column model text'
|
'alter table devices add column model text',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const db = require('./db')
|
||||||
|
|
||||||
module.exports.up = function (next) {
|
module.exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'alter table user_config add column schema_version smallint not null DEFAULT 1'
|
'alter table user_config add column schema_version smallint not null DEFAULT 1',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['ALTER TABLE customers ADD COLUMN suspended_until timestamptz']
|
||||||
"ALTER TABLE customers ADD COLUMN suspended_until timestamptz"
|
|
||||||
]
|
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['ALTER TABLE user_tokens ADD COLUMN last_accessed timestamptz']
|
||||||
'ALTER TABLE user_tokens ADD COLUMN last_accessed timestamptz',
|
|
||||||
]
|
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'drop table if exists support_logs',
|
'drop table if exists support_logs',
|
||||||
'drop table if exists server_support_logs'
|
'drop table if exists server_support_logs',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql =
|
const sql = [
|
||||||
[
|
`CREATE TABLE coupons (
|
||||||
`CREATE TABLE coupons (
|
|
||||||
id UUID PRIMARY KEY,
|
id UUID PRIMARY KEY,
|
||||||
code TEXT NOT NULL,
|
code TEXT NOT NULL,
|
||||||
discount SMALLINT NOT NULL,
|
discount SMALLINT NOT NULL,
|
||||||
soft_deleted BOOLEAN DEFAULT false )`,
|
soft_deleted BOOLEAN DEFAULT false )`,
|
||||||
`CREATE UNIQUE INDEX uq_code ON coupons (code) WHERE NOT soft_deleted`
|
`CREATE UNIQUE INDEX uq_code ON coupons (code) WHERE NOT soft_deleted`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const db = require('./db')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'ALTER TABLE cash_in_txs ADD COLUMN discount SMALLINT',
|
'ALTER TABLE cash_in_txs ADD COLUMN discount SMALLINT',
|
||||||
'ALTER TABLE cash_out_txs ADD COLUMN discount SMALLINT'
|
'ALTER TABLE cash_out_txs ADD COLUMN discount SMALLINT',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'ALTER TABLE bills DROP COLUMN crypto_atoms',
|
'ALTER TABLE bills DROP COLUMN crypto_atoms',
|
||||||
'ALTER TABLE bills DROP COLUMN cash_in_fee_crypto',
|
'ALTER TABLE bills DROP COLUMN cash_in_fee_crypto',
|
||||||
'ALTER TABLE bills DROP COLUMN crypto_atoms_after_fee'
|
'ALTER TABLE bills DROP COLUMN crypto_atoms_after_fee',
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
const singleQuotify = (item) => `'${item}'`
|
const singleQuotify = item => `'${item}'`
|
||||||
|
|
||||||
var types = [
|
var types = [
|
||||||
'highValueTransaction',
|
'highValueTransaction',
|
||||||
|
|
@ -8,7 +8,7 @@ var types = [
|
||||||
'fiatBalance',
|
'fiatBalance',
|
||||||
'cryptoBalance',
|
'cryptoBalance',
|
||||||
'compliance',
|
'compliance',
|
||||||
'error'
|
'error',
|
||||||
]
|
]
|
||||||
.map(singleQuotify)
|
.map(singleQuotify)
|
||||||
.join(',')
|
.join(',')
|
||||||
|
|
@ -27,7 +27,7 @@ exports.up = function (next) {
|
||||||
"valid" BOOLEAN NOT NULL DEFAULT 'true'
|
"valid" BOOLEAN NOT NULL DEFAULT 'true'
|
||||||
);
|
);
|
||||||
CREATE INDEX ON notifications (valid);
|
CREATE INDEX ON notifications (valid);
|
||||||
CREATE INDEX ON notifications (read);`
|
CREATE INDEX ON notifications (read);`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ exports.up = function (next) {
|
||||||
`ALTER TABLE blacklist DROP CONSTRAINT blacklist_crypto_code_address_key`,
|
`ALTER TABLE blacklist DROP CONSTRAINT blacklist_crypto_code_address_key`,
|
||||||
`ALTER TABLE blacklist ADD CONSTRAINT blacklist_crypto_code_address_created_by_operator_key UNIQUE (crypto_code, address, created_by_operator)`,
|
`ALTER TABLE blacklist ADD CONSTRAINT blacklist_crypto_code_address_created_by_operator_key UNIQUE (crypto_code, address, created_by_operator)`,
|
||||||
`CREATE INDEX ON blacklist (created_by_operator)`,
|
`CREATE INDEX ON blacklist (created_by_operator)`,
|
||||||
`REINDEX TABLE blacklist`
|
`REINDEX TABLE blacklist`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = ['ALTER TABLE customers ADD COLUMN id_card_data_raw text']
|
||||||
'ALTER TABLE customers ADD COLUMN id_card_data_raw text'
|
|
||||||
]
|
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ exports.up = function (next) {
|
||||||
FOREIGN KEY (cashbox_batch_id)
|
FOREIGN KEY (cashbox_batch_id)
|
||||||
REFERENCES cashbox_batches (id)`,
|
REFERENCES cashbox_batches (id)`,
|
||||||
|
|
||||||
`UPDATE bills SET legacy = 'true'`
|
`UPDATE bills SET legacy = 'true'`,
|
||||||
]
|
]
|
||||||
db.multi(sqls, next)
|
db.multi(sqls, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ exports.up = function (next) {
|
||||||
tx_id uuid REFERENCES cash_in_txs(id),
|
tx_id uuid REFERENCES cash_in_txs(id),
|
||||||
trade_id serial REFERENCES trades(id),
|
trade_id serial REFERENCES trades(id),
|
||||||
CONSTRAINT cashin_trade_pkey PRIMARY KEY (tx_id,trade_id)
|
CONSTRAINT cashin_trade_pkey PRIMARY KEY (tx_id,trade_id)
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -4,37 +4,43 @@ const settingsLoader = require('../lib/new-settings-loader')
|
||||||
const configManager = require('../lib/new-config-manager')
|
const configManager = require('../lib/new-config-manager')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
return db.tx(async t => {
|
return db
|
||||||
const settingsPromise = settingsLoader.loadLatestConfig()
|
.tx(async t => {
|
||||||
const machinesPromise = t.any('SELECT device_id FROM devices')
|
const settingsPromise = settingsLoader.loadLatestConfig()
|
||||||
const [config, machines] = await Promise.all([settingsPromise, machinesPromise])
|
const machinesPromise = t.any('SELECT device_id FROM devices')
|
||||||
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
|
const [config, machines] = await Promise.all([
|
||||||
|
settingsPromise,
|
||||||
|
machinesPromise,
|
||||||
|
])
|
||||||
|
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
|
||||||
|
|
||||||
const deviceIds = _.map(_.get('device_id'))(machines)
|
const deviceIds = _.map(_.get('device_id'))(machines)
|
||||||
const getZeroConfLimit = _.compose(_.get('zeroConfLimit'), it => configManager.getCashOut(it, config))
|
const getZeroConfLimit = _.compose(_.get('zeroConfLimit'), it =>
|
||||||
const zeroConfLimits = _.map(getZeroConfLimit)(deviceIds)
|
configManager.getCashOut(it, config),
|
||||||
|
)
|
||||||
|
const zeroConfLimits = _.map(getZeroConfLimit)(deviceIds)
|
||||||
|
|
||||||
const configMin = _.min(zeroConfLimits)
|
const configMin = _.min(zeroConfLimits)
|
||||||
const smallerZeroConf = _.isFinite(configMin) ? Number(configMin) : 0
|
const smallerZeroConf = _.isFinite(configMin) ? Number(configMin) : 0
|
||||||
|
|
||||||
_.forEach(cryptoCode => {
|
_.forEach(cryptoCode => {
|
||||||
const walletConfig = configManager.getWalletSettings(cryptoCode, config)
|
const walletConfig = configManager.getWalletSettings(cryptoCode, config)
|
||||||
const zeroConfLimit = _.get('zeroConfLimit', walletConfig)
|
const zeroConfLimit = _.get('zeroConfLimit', walletConfig)
|
||||||
|
|
||||||
if (_.isNil(zeroConfLimit)) {
|
if (_.isNil(zeroConfLimit)) {
|
||||||
config[`wallets_${cryptoCode}_zeroConfLimit`] = smallerZeroConf
|
config[`wallets_${cryptoCode}_zeroConfLimit`] = smallerZeroConf
|
||||||
}
|
}
|
||||||
}, cryptoCodes)
|
}, cryptoCodes)
|
||||||
|
|
||||||
_.forEach(deviceId => {
|
_.forEach(deviceId => {
|
||||||
const key = `cashOut_${deviceId}_zeroConfLimit`
|
const key = `cashOut_${deviceId}_zeroConfLimit`
|
||||||
if (_.has(key, config)) {
|
if (_.has(key, config)) {
|
||||||
config[key] = null
|
config[key] = null
|
||||||
}
|
}
|
||||||
})(deviceIds)
|
})(deviceIds)
|
||||||
|
|
||||||
return settingsLoader.migrationSaveConfig(config)
|
return settingsLoader.migrationSaveConfig(config)
|
||||||
})
|
})
|
||||||
.then(() => next())
|
.then(() => next())
|
||||||
.catch(err => next(err))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ exports.up = function (next) {
|
||||||
)`,
|
)`,
|
||||||
`ALTER TABLE cashbox_batches ADD COLUMN operation_type cashbox_batch_type NOT NULL`,
|
`ALTER TABLE cashbox_batches ADD COLUMN operation_type cashbox_batch_type NOT NULL`,
|
||||||
`ALTER TABLE cashbox_batches ADD COLUMN bill_count_override SMALLINT`,
|
`ALTER TABLE cashbox_batches ADD COLUMN bill_count_override SMALLINT`,
|
||||||
`ALTER TABLE cashbox_batches ADD COLUMN performed_by VARCHAR(64)`
|
`ALTER TABLE cashbox_batches ADD COLUMN performed_by VARCHAR(64)`,
|
||||||
]
|
]
|
||||||
db.multi(sqls, next)
|
db.multi(sqls, next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const { migrationSaveConfig } = require('../lib/new-settings-loader')
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const triggersDefault = {
|
const triggersDefault = {
|
||||||
triggersConfig_expirationTime: 'Forever',
|
triggersConfig_expirationTime: 'Forever',
|
||||||
triggersConfig_automation: 'Automatic'
|
triggersConfig_automation: 'Automatic',
|
||||||
}
|
}
|
||||||
|
|
||||||
return migrationSaveConfig(triggersDefault)
|
return migrationSaveConfig(triggersDefault)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const _ = require('lodash/fp')
|
||||||
const settingsLoader = require('../lib/new-settings-loader')
|
const settingsLoader = require('../lib/new-settings-loader')
|
||||||
const configManager = require('../lib/new-config-manager')
|
const configManager = require('../lib/new-config-manager')
|
||||||
|
|
||||||
exports.up = async function (next) {
|
exports.up = async function () {
|
||||||
const config = await settingsLoader.loadLatestConfig()
|
const config = await settingsLoader.loadLatestConfig()
|
||||||
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
|
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
|
||||||
_.forEach(cryptoCode => {
|
_.forEach(cryptoCode => {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ exports.up = function (next) {
|
||||||
`ALTER TABLE compliance_overrides DROP COLUMN override_by`,
|
`ALTER TABLE compliance_overrides DROP COLUMN override_by`,
|
||||||
`ALTER TABLE compliance_overrides ADD COLUMN override_by UUID REFERENCES users(id)`,
|
`ALTER TABLE compliance_overrides ADD COLUMN override_by UUID REFERENCES users(id)`,
|
||||||
`DROP TABLE IF EXISTS one_time_passes`,
|
`DROP TABLE IF EXISTS one_time_passes`,
|
||||||
`DROP TABLE IF EXISTS user_tokens`
|
`DROP TABLE IF EXISTS user_tokens`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
const { migrationSaveConfig, loadLatestConfig } = require('../lib/new-settings-loader')
|
const {
|
||||||
|
migrationSaveConfig,
|
||||||
|
loadLatestConfig,
|
||||||
|
} = require('../lib/new-settings-loader')
|
||||||
const CASSETTE_MAX_CAPACITY = 500
|
const CASSETTE_MAX_CAPACITY = 500
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
|
|
@ -12,19 +15,31 @@ exports.up = function (next) {
|
||||||
const overrides = config.notifications_fiatBalanceOverrides
|
const overrides = config.notifications_fiatBalanceOverrides
|
||||||
const newConfig = {}
|
const newConfig = {}
|
||||||
if (fiatBalance1) {
|
if (fiatBalance1) {
|
||||||
newConfig.notifications_fillingPercentageCassette1 = (100 * (fiatBalance1 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newConfig.notifications_fillingPercentageCassette1 = (
|
||||||
|
100 *
|
||||||
|
(fiatBalance1 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
newConfig.notifications_fiatBalanceCassette1 = null
|
newConfig.notifications_fiatBalanceCassette1 = null
|
||||||
}
|
}
|
||||||
if (fiatBalance2) {
|
if (fiatBalance2) {
|
||||||
newConfig.notifications_fillingPercentageCassette2 = (100 * (fiatBalance2 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newConfig.notifications_fillingPercentageCassette2 = (
|
||||||
|
100 *
|
||||||
|
(fiatBalance2 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
newConfig.notifications_fiatBalanceCassette2 = null
|
newConfig.notifications_fiatBalanceCassette2 = null
|
||||||
}
|
}
|
||||||
if (fiatBalance3) {
|
if (fiatBalance3) {
|
||||||
newConfig.notifications_fillingPercentageCassette3 = (100 * (fiatBalance3 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newConfig.notifications_fillingPercentageCassette3 = (
|
||||||
|
100 *
|
||||||
|
(fiatBalance3 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
newConfig.notifications_fiatBalanceCassette3 = null
|
newConfig.notifications_fiatBalanceCassette3 = null
|
||||||
}
|
}
|
||||||
if (fiatBalance4) {
|
if (fiatBalance4) {
|
||||||
newConfig.notifications_fillingPercentageCassette4 = (100 * (fiatBalance4 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newConfig.notifications_fillingPercentageCassette4 = (
|
||||||
|
100 *
|
||||||
|
(fiatBalance4 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
newConfig.notifications_fiatBalanceCassette4 = null
|
newConfig.notifications_fiatBalanceCassette4 = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,16 +47,28 @@ exports.up = function (next) {
|
||||||
newConfig.notifications_fiatBalanceOverrides = _.map(override => {
|
newConfig.notifications_fiatBalanceOverrides = _.map(override => {
|
||||||
const newOverride = {}
|
const newOverride = {}
|
||||||
if (override.fiatBalanceCassette1) {
|
if (override.fiatBalanceCassette1) {
|
||||||
newOverride.fillingPercentageCassette1 = (100 * (override.fiatBalanceCassette1 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newOverride.fillingPercentageCassette1 = (
|
||||||
|
100 *
|
||||||
|
(override.fiatBalanceCassette1 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
}
|
}
|
||||||
if (override.fiatBalanceCassette2) {
|
if (override.fiatBalanceCassette2) {
|
||||||
newOverride.fillingPercentageCassette2 = (100 * (override.fiatBalanceCassette2 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newOverride.fillingPercentageCassette2 = (
|
||||||
|
100 *
|
||||||
|
(override.fiatBalanceCassette2 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
}
|
}
|
||||||
if (override.fiatBalanceCassette3) {
|
if (override.fiatBalanceCassette3) {
|
||||||
newOverride.fillingPercentageCassette3 = (100 * (override.fiatBalanceCassette3 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newOverride.fillingPercentageCassette3 = (
|
||||||
|
100 *
|
||||||
|
(override.fiatBalanceCassette3 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
}
|
}
|
||||||
if (override.fiatBalanceCassette4) {
|
if (override.fiatBalanceCassette4) {
|
||||||
newOverride.fillingPercentageCassette4 = (100 * (override.fiatBalanceCassette4 / CASSETTE_MAX_CAPACITY)).toFixed(0)
|
newOverride.fillingPercentageCassette4 = (
|
||||||
|
100 *
|
||||||
|
(override.fiatBalanceCassette4 / CASSETTE_MAX_CAPACITY)
|
||||||
|
).toFixed(0)
|
||||||
}
|
}
|
||||||
newOverride.machine = override.machine
|
newOverride.machine = override.machine
|
||||||
newOverride.id = override.id
|
newOverride.id = override.id
|
||||||
|
|
@ -49,8 +76,7 @@ exports.up = function (next) {
|
||||||
return newOverride
|
return newOverride
|
||||||
}, config.notifications_fiatBalanceOverrides)
|
}, config.notifications_fiatBalanceOverrides)
|
||||||
}
|
}
|
||||||
return migrationSaveConfig(newConfig)
|
return migrationSaveConfig(newConfig).then(() => next())
|
||||||
.then(() => next())
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err.message)
|
console.log(err.message)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ exports.up = function (next) {
|
||||||
approved BOOLEAN,
|
approved BOOLEAN,
|
||||||
customer_data JSONB NOT NULL,
|
customer_data JSONB NOT NULL,
|
||||||
PRIMARY KEY(customer_id, info_request_id)
|
PRIMARY KEY(customer_id, info_request_id)
|
||||||
);`
|
);`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,14 @@ const _ = require('lodash/fp')
|
||||||
const settingsLoader = require('../lib/new-settings-loader')
|
const settingsLoader = require('../lib/new-settings-loader')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
settingsLoader.loadLatestConfig()
|
settingsLoader
|
||||||
|
.loadLatestConfig()
|
||||||
.then(config => {
|
.then(config => {
|
||||||
if (!_.isEmpty(config))
|
if (!_.isEmpty(config)) config.locale_timezone = '0:0'
|
||||||
config.locale_timezone = '0:0'
|
|
||||||
return settingsLoader.migrationSaveConfig(config)
|
return settingsLoader.migrationSaveConfig(config)
|
||||||
})
|
})
|
||||||
.then(() => next())
|
.then(() => next())
|
||||||
.catch(err => next(err))
|
.catch(err => next(err))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.down = function (next) {
|
exports.down = function (next) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ exports.up = function (next) {
|
||||||
created TIMESTAMPTZ DEFAULT now(),
|
created TIMESTAMPTZ DEFAULT now(),
|
||||||
last_used TIMESTAMPTZ DEFAULT now(),
|
last_used TIMESTAMPTZ DEFAULT now(),
|
||||||
data JSONB NOT NULL
|
data JSONB NOT NULL
|
||||||
)`
|
)`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,17 @@
|
||||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
const { migrationSaveConfig } = require('../lib/new-settings-loader')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const newConfig = {
|
const newConfig = {
|
||||||
cashIn_cashboxReset: 'Manual'
|
cashIn_cashboxReset: 'Manual',
|
||||||
}
|
}
|
||||||
return loadLatest()
|
return migrationSaveConfig(newConfig)
|
||||||
.then(config => {
|
.then(() => next())
|
||||||
return migrationSaveConfig(newConfig)
|
.catch(err => {
|
||||||
.then(() => next())
|
if (err.message === 'lamassu-server is not configured') {
|
||||||
.catch(err => {
|
return next()
|
||||||
if (err.message === 'lamassu-server is not configured') {
|
}
|
||||||
return next()
|
console.log(err.message)
|
||||||
}
|
return next(err)
|
||||||
console.log(err.message)
|
|
||||||
return next(err)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ const db = require('./db')
|
||||||
const { migrationSaveConfig } = require('../lib/new-settings-loader')
|
const { migrationSaveConfig } = require('../lib/new-settings-loader')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const sql = [
|
const sql = [`ALTER TYPE notification_type ADD VALUE 'security'`]
|
||||||
`ALTER TYPE notification_type ADD VALUE 'security'`
|
|
||||||
]
|
|
||||||
|
|
||||||
const newConfig = {}
|
const newConfig = {}
|
||||||
newConfig.notifications_email_security = true
|
newConfig.notifications_email_security = true
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ exports.up = function (next) {
|
||||||
)`,
|
)`,
|
||||||
`ALTER TABLE cash_in_txs ADD COLUMN batch_id UUID REFERENCES transaction_batches(id)`,
|
`ALTER TABLE cash_in_txs ADD COLUMN batch_id UUID REFERENCES transaction_batches(id)`,
|
||||||
`ALTER TABLE cash_in_txs ADD COLUMN batched BOOLEAN NOT NULL DEFAULT false`,
|
`ALTER TABLE cash_in_txs ADD COLUMN batched BOOLEAN NOT NULL DEFAULT false`,
|
||||||
`ALTER TABLE cash_in_txs ADD COLUMN batch_time TIMESTAMPTZ`
|
`ALTER TABLE cash_in_txs ADD COLUMN batch_time TIMESTAMPTZ`,
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue