in source/packages/services/assetlibrary/src/init/init.full.dao.ts [103:211]
public async upgrade_from_0(): Promise<void> {
logger.debug(`init.dao upgrade_from_0: in:`);
const conn = await super.getConnection();
// set groupPath of root group '/'
await conn.traversal.V('group___/').property('groupPath', '/').iterate();
await conn.traversal
.V('type___device')
.as('type')
// add missing template id
.property(process.cardinality.single, 'templateId', 'device')
// add type definition for the root device template
.addV('typeDefinition')
.property(process.t.id, 'type___device___1')
.property(process.cardinality.single, 'version', 1)
.property(
process.cardinality.single,
'definition',
JSON.stringify({
properties: {
deviceId: {
type: 'string',
},
templateId: {
type: 'string',
},
category: {
type: ['string', 'null'],
const: 'device',
},
name: {
type: 'string',
},
description: {
type: ['string', 'null'],
},
imageUrl: {
type: ['string', 'null'],
},
awsIotThingArn: {
type: ['string', 'null'],
},
connected: {
type: 'boolean',
},
state: {
enum: ['unprovisioned', 'active', 'decommisioned', 'retired'],
},
},
required: ['deviceId', 'templateId'],
})
)
.property(process.cardinality.single, 'lastUpdated', new Date().toISOString())
.as('definition')
.addE('current_definition')
.property('status', 'published')
.from_('type')
.to('definition')
.next();
// add type definition for the root group template
await conn.traversal
.V('type___group')
.as('type')
// add missing template id
.property(process.cardinality.single, 'templateId', 'group')
// add type definition for the root group template
.addV('typeDefinition')
.property(process.t.id, 'type___group___1')
.property(process.cardinality.single, 'version', 1)
.property(
process.cardinality.single,
'definition',
JSON.stringify({
properties: {
groupPath: {
type: 'string',
},
parentPath: {
type: 'string',
},
templateId: {
type: 'string',
},
category: {
type: ['string'],
const: 'group',
},
name: {
type: 'string',
},
description: {
type: ['string', 'null'],
},
},
required: ['name', 'parentPath', 'templateId'],
})
)
.property(process.cardinality.single, 'lastUpdated', new Date().toISOString())
.as('definition')
.addE('current_definition')
.property('status', 'published')
.from_('type')
.to('definition')
.next();
logger.debug(`init.dao upgrade_from_0: exit:`);
}