neopg 2.2.3 → 2.2.4
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.
- package/lib/SchemaSync.js +12 -2
- package/lib/dataTypes.js +9 -0
- package/package.json +1 -1
- package/test/test-db.js +11 -1
package/lib/SchemaSync.js
CHANGED
|
@@ -311,7 +311,17 @@ class SchemaSync {
|
|
|
311
311
|
`;
|
|
312
312
|
|
|
313
313
|
if (exist.length > 0) continue;
|
|
314
|
-
|
|
314
|
+
let using_text = '';
|
|
315
|
+
if (typeof indname === 'string' && def.columns[indname]) {
|
|
316
|
+
if (!def.columns[indname].indexType) {
|
|
317
|
+
if (def.columns[indname].type.toLowerCase() === 'jsonb' || def.columns[indname].type.includes('[')) {
|
|
318
|
+
using_text = `USING GIN`;
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
using_text = `USING ${def.columns[indname].indexType}`;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
await sql.unsafe(`CREATE INDEX ${targetIdxName} ON ${curTableName} ${using_text} (${idxCols.map(c=>this.fmtColName(c)).join(',')})`);
|
|
315
325
|
}
|
|
316
326
|
}
|
|
317
327
|
|
|
@@ -352,7 +362,7 @@ class SchemaSync {
|
|
|
352
362
|
|
|
353
363
|
if (exist.length > 0) continue;
|
|
354
364
|
|
|
355
|
-
await sql.unsafe(`CREATE UNIQUE INDEX ON ${curTableName} (${idxCols.map(c=>this.fmtColName(c)).join(',')})`);
|
|
365
|
+
await sql.unsafe(`CREATE UNIQUE INDEX ${targetIdxName} ON ${curTableName} (${idxCols.map(c=>this.fmtColName(c)).join(',')})`);
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
368
|
|
package/lib/dataTypes.js
CHANGED
|
@@ -45,6 +45,15 @@ let types = {
|
|
|
45
45
|
SERIAL: 'serial',
|
|
46
46
|
BIGSERIAL: 'bigserial',
|
|
47
47
|
BigSerial: 'bigserial',
|
|
48
|
+
|
|
49
|
+
//几何类型
|
|
50
|
+
POINT: 'point',
|
|
51
|
+
LINE: 'LINE',
|
|
52
|
+
LSEG: 'lseg',
|
|
53
|
+
BOX: 'box',
|
|
54
|
+
PATH: 'path',
|
|
55
|
+
POLYGON: 'polygon',
|
|
56
|
+
CIRCLE: 'circle'
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
types.DECIMAL = types.NUMBER
|
package/package.json
CHANGED
package/test/test-db.js
CHANGED
|
@@ -122,6 +122,14 @@ const User = {
|
|
|
122
122
|
is_root: {
|
|
123
123
|
type: dataTypes.SMALLINT,
|
|
124
124
|
default: 0
|
|
125
|
+
},
|
|
126
|
+
skills: {
|
|
127
|
+
type: dataTypes.ARRAY(dataTypes.STRING(30))
|
|
128
|
+
},
|
|
129
|
+
points: {
|
|
130
|
+
type: dataTypes.POINT,
|
|
131
|
+
default: '(0,0)',
|
|
132
|
+
indexType: 'GiST'
|
|
125
133
|
}
|
|
126
134
|
},
|
|
127
135
|
|
|
@@ -130,7 +138,9 @@ const User = {
|
|
|
130
138
|
'create_time',
|
|
131
139
|
'level',
|
|
132
140
|
'is_root',
|
|
133
|
-
['level', 'is_root']
|
|
141
|
+
['level', 'is_root'],
|
|
142
|
+
'skills',
|
|
143
|
+
'points'
|
|
134
144
|
],
|
|
135
145
|
|
|
136
146
|
//唯一索引
|