mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 13:53:22 +02:00
update built-in objects in the database (#846)
Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
|
||||
* Copyright © 2019-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
|
||||
**/
|
||||
|
||||
module.exports.command = 'migrate'
|
||||
@@ -23,20 +23,23 @@ module.exports.handler = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
return dbapi.getGroupByIndex(apiutil.ROOT, 'privilege').then(function(group) {
|
||||
// signatures of built-in objects are defined
|
||||
const env = {
|
||||
STF_ROOT_GROUP_NAME: group ? group.name : 'Common'
|
||||
, STF_ADMIN_NAME: group ? group.owner.name : 'administrator'
|
||||
, STF_ADMIN_EMAIL: group ? group.owner.email : 'administrator@fakedomain.com'
|
||||
}
|
||||
for (const i in env) {
|
||||
if (process.env[i]) {
|
||||
env[i] = process.env[i]
|
||||
}
|
||||
}
|
||||
if (!group) {
|
||||
const env = {
|
||||
STF_ROOT_GROUP_NAME: 'Common'
|
||||
, STF_ADMIN_NAME: 'administrator'
|
||||
, STF_ADMIN_EMAIL: 'administrator@fakedomain.com'
|
||||
}
|
||||
for (const i in env) {
|
||||
if (process.env[i]) {
|
||||
env[i] = process.env[i]
|
||||
}
|
||||
}
|
||||
// root group does not exist, so bootstrap is created
|
||||
return dbapi.createBootStrap(env)
|
||||
}
|
||||
return group
|
||||
// bootstrap is updated with new signatures
|
||||
return dbapi.updateBootStrap(group, env)
|
||||
})
|
||||
.then(function() {
|
||||
resolve(true)
|
||||
|
||||
Reference in New Issue
Block a user