doix-db 1.0.5 → 1.0.7

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.
@@ -7,12 +7,14 @@ const OBJECT_ACTIONS = [
7
7
  'alter',
8
8
  'migrate',
9
9
  'recreate',
10
+ 'comment',
10
11
  ]
11
12
 
12
13
  const COLUMN_ACTIONS = [
13
14
  'add-column',
14
15
  'alter-column',
15
16
  'migrate-column',
17
+ 'comment-column',
16
18
  ]
17
19
 
18
20
  const add = (toDo, action, object) => {
@@ -40,17 +42,25 @@ class DbMigrationPlan extends EventEmitter {
40
42
 
41
43
  this.toDo = new Map
42
44
 
43
- for (const action of OBJECT_ACTIONS)
44
-
45
- this.on (action, object => add (
46
- this.toDo,
47
- action, object))
48
-
49
- for (const action of COLUMN_ACTIONS)
50
-
51
- this.on (action, column => add (
52
- this.asIs.get (column.relation.name).toDo,
53
- action, column))
45
+ for (const action of OBJECT_ACTIONS) this.on (action, object => add (
46
+ this.toDo,
47
+ action, object)
48
+ )
49
+
50
+ this.on ('create', object => add (
51
+ this.toDo,
52
+ 'comment', object)
53
+ )
54
+
55
+ for (const action of COLUMN_ACTIONS) this.on (action, column => add (
56
+ this.asIs.get (column.relation.name).toDo,
57
+ action, column)
58
+ )
59
+
60
+ for (const action of ['add-column', 'migrate-column']) this.on (action, column => add (
61
+ this.asIs.get (column.relation.name).toDo,
62
+ 'comment-column', column)
63
+ )
54
64
 
55
65
  }
56
66
 
@@ -70,6 +80,8 @@ class DbMigrationPlan extends EventEmitter {
70
80
 
71
81
  if (action !== null) this.emit (action, column)
72
82
 
83
+ if (existingColumn.comment != column.comment) this.emit ('comment-column', column)
84
+
73
85
  }
74
86
  else {
75
87
 
@@ -83,6 +95,8 @@ class DbMigrationPlan extends EventEmitter {
83
95
 
84
96
  compareObject (asIs, toBe) {
85
97
 
98
+ if (asIs.comment != toBe.comment) this.emit ('comment', toBe)
99
+
86
100
  if (asIs.constructor === toBe.constructor && toBe instanceof DbRelation)
87
101
 
88
102
  this.compareRelation (asIs, toBe)
@@ -53,13 +53,17 @@ class DbRelation extends DbObject {
53
53
  for (const col of Object.values (this.columns)) col.setLang (lang)
54
54
 
55
55
  const {keys} = this; for (const k in keys) {
56
-
57
- const index = new DbIndex (keys [k], this, k)
58
56
 
59
- index.setLang (lang)
60
-
61
- keys [k] = index
57
+ const v = keys [k]; if (v !== null) {
58
+
59
+ const index = new DbIndex (v, this, k)
62
60
 
61
+ index.setLang (lang)
62
+
63
+ keys [k] = index
64
+
65
+ }
66
+
63
67
  }
64
68
 
65
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doix-db",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Shared database related code for doix",
5
5
  "main": "index.js",
6
6
  "files": [