Fix migrate-tools for multiple devices (#113)
Don't fail with duplicate key errors if there is more than one row already in the devices table, since it attempts to update the device_id column.
This commit is contained in:
parent
a6512ceb1e
commit
fd659c88c6
1 changed files with 2 additions and 2 deletions
|
|
@ -7,10 +7,10 @@ const machineLoader = require('../lib/machine-loader')
|
||||||
module.exports = {migrateNames}
|
module.exports = {migrateNames}
|
||||||
|
|
||||||
function migrateNames () {
|
function migrateNames () {
|
||||||
const cs = new pgp.helpers.ColumnSet(['device_id', 'name'], {table: 'devices'})
|
const cs = new pgp.helpers.ColumnSet(['?device_id', 'name'], {table: 'devices'})
|
||||||
|
|
||||||
return settingsLoader.loadLatest()
|
return settingsLoader.loadLatest()
|
||||||
.then(r => machineLoader.getMachineNames(r.config))
|
.then(r => machineLoader.getMachineNames(r.config))
|
||||||
.then(_.map(r => ({device_id: r.deviceId, name: r.name})))
|
.then(_.map(r => ({device_id: r.deviceId, name: r.name})))
|
||||||
.then(data => pgp.helpers.update(data, cs))
|
.then(data => pgp.helpers.update(data, cs) + ' WHERE t.device_id=v.device_id')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue