upgrade data - hooked up to server & builder
This commit is contained in:
parent
9ee1132185
commit
3429311d5e
|
@ -74,6 +74,9 @@ export const getPotentialReferenceIndexes = (hierarchy, record) =>
|
|||
),
|
||||
])
|
||||
|
||||
export const isIndex = hierarchyFunctions.isIndex
|
||||
export const isRecord = hierarchyFunctions.isRecord
|
||||
|
||||
export const getDefaultTypeOptions = type =>
|
||||
!type ? {} : allTypes[type].getDefaultOptions()
|
||||
|
||||
|
|
|
@ -24,20 +24,23 @@ import { cloneApp } from "../appInitialise/cloneApp"
|
|||
import { initialiseData } from "../appInitialise/initialiseData"
|
||||
import { initialiseChildrenForNode } from "../recordApi/initialiseChildren"
|
||||
import { initialiseNewIndex } from "./initialiseNewIndex"
|
||||
import { saveApplicationHierarchy } from "../templateApi/saveApplicationHierarchy"
|
||||
import { _saveApplicationHierarchy } from "../templateApi/saveApplicationHierarchy"
|
||||
import { getApplicationDefinition } from "../templateApi/getApplicationDefinition"
|
||||
|
||||
export const upgradeData = app => async newHierarchy => {
|
||||
const currentAppDef = await getApplicationDefinition(app.datastore)()
|
||||
app.hierarchy = currentAppDef.hierarchy
|
||||
newHierarchy = constructHierarchy(newHierarchy)
|
||||
const diff = diffHierarchy(app.hierarchy, newHierarchy)
|
||||
const changeActions = gatherChangeActions(diff)
|
||||
|
||||
if (changeActions.length === 0) return
|
||||
|
||||
newHierarchy = constructHierarchy(newHierarchy)
|
||||
const newApp = newHierarchy && cloneApp(app, {
|
||||
hierarchy: newHierarchy
|
||||
})
|
||||
await doUpgrade(app, newApp, changeActions)
|
||||
await saveApplicationHierarchy(newApp)(newHierarchy)
|
||||
await _saveApplicationHierarchy(newApp.datastore, newHierarchy)
|
||||
}
|
||||
|
||||
const gatherChangeActions = (diff) =>
|
||||
|
|
|
@ -18,7 +18,7 @@ const lookupField = require("./lookupField")
|
|||
const getRecord = require("./getRecord")
|
||||
const deleteRecord = require("./deleteRecord")
|
||||
const saveAppHierarchy = require("./saveAppHierarchy")
|
||||
const upgradeData = require("./saveAppHierarchy")
|
||||
const upgradeData = require("./upgradeData")
|
||||
|
||||
module.exports = {
|
||||
authenticate,
|
||||
|
|
|
@ -155,7 +155,6 @@ module.exports = (config, app) => {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
.get("/_builder/api/:appname/componentlibrary", async ctx => {
|
||||
const info = await componentLibraryInfo(
|
||||
config,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"build": "cd appPackages/_master && yarn && cd ../testApp && yarn && cd ../testApp2 && yarn",
|
||||
"initialise": "node ./initialise/initialiseBudibase init -d ./myapps -c contributors -u admin -p admin",
|
||||
"budi": "node ../cli/bin/budi",
|
||||
"dev:builder": "node index"
|
||||
"dev:builder": "node index --enable-source-maps"
|
||||
},
|
||||
"keywords": [
|
||||
"budibase"
|
||||
|
|
Loading…
Reference in New Issue