@live-change/framework 0.7.34 → 0.7.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  const utils = require("../utils.js")
2
2
  const debug = require('debug')('framework:updaters:db')
3
+
3
4
  async function update(changes, service, app, force) {
4
5
 
5
6
  const dao = app.dao
@@ -116,7 +117,8 @@ async function update(changes, service, app, force) {
116
117
 
117
118
  debug("DATABASE UPDATER")
118
119
 
119
- for(let change of changes) {
120
+ for(let i = 0; i < changes.length; i++) {
121
+ const change = changes[i]
120
122
  debug("PROCESSING CHANGE", change)
121
123
  switch(change.operation) {
122
124
  case "createModel": {
@@ -124,9 +126,18 @@ async function update(changes, service, app, force) {
124
126
  const tableName = generateTableName(model.name)
125
127
  await dao.request(['database', 'createTable'], database, tableName, model.storage ?? {})
126
128
  debug("TABLE CREATED!", tableName)
127
- for(let indexName in model.indexes) {
128
- const index = model.indexes[indexName]
129
+ for(const [indexName, index] of Object.entries(model.indexes || {})) {
130
+ if(index.created) continue
131
+ if(index.dependsOn) {
132
+ const dependsOn = Array.isArray(index.dependsOn) ? index.dependsOn : [index.dependsOn]
133
+ for(const indexName of dependsOn) {
134
+ const index = model.indexes[indexName]
135
+ await createIndex(tableName, indexName, index)
136
+ index.created = true
137
+ }
138
+ }
129
139
  await createIndex(tableName, indexName, index)
140
+ index.created = true
130
141
  }
131
142
  } break
132
143
  case "renameModel": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/framework",
3
- "version": "0.7.34",
3
+ "version": "0.7.36",
4
4
  "description": "Live Change Framework - ultimate solution for real time mobile/web apps",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,7 +27,7 @@
27
27
  "@live-change/db-store-level": "0.6.23",
28
28
  "@live-change/db-store-lmdb": "0.6.23",
29
29
  "@live-change/sockjs": "0.4.1",
30
- "@live-change/uid": "^0.7.34",
30
+ "@live-change/uid": "^0.7.36",
31
31
  "cookie": "^0.4.1",
32
32
  "express": "^4.18.2",
33
33
  "os-service": "^2.2.0",
@@ -35,5 +35,5 @@
35
35
  "tape": "^5.3.2",
36
36
  "websocket": "^1.0.34"
37
37
  },
38
- "gitHead": "730c14caf86069665193ce157b2663358abef342"
38
+ "gitHead": "23f7ed337f9bb45ed698b0e72959720076b6222c"
39
39
  }