update built-in objects in the database (#846)

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
Denis Barbaron
2025-03-07 20:51:25 +01:00
committed by GitHub
parent 9de3828158
commit 4e8a5a1cef
3 changed files with 188 additions and 19 deletions

View File

@@ -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)