pangea-server 3.3.119 → 3.3.120

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.
@@ -50,9 +50,10 @@ function Table(tableName, options = {}) {
50
50
  underscored: true,
51
51
  timestamps: true,
52
52
  paranoid: true,
53
- indexes: allIndexes.map(({ field, fields, ...restIndex }) => ({
54
- ...restIndex,
55
- fields: fields ? fields.map(pangea_helpers_1.camelToSnake) : field ? [(0, pangea_helpers_1.camelToSnake)(field)] : [],
53
+ indexes: allIndexes.map((index) => ({
54
+ name: getIndexName(tableName, index),
55
+ fields: getIndexFields(index),
56
+ unique: index.unique,
56
57
  })),
57
58
  })(target);
58
59
  const hiddenAttributes = target.HiddenAttributes;
@@ -62,3 +63,15 @@ function Table(tableName, options = {}) {
62
63
  seq.Scopes(() => ({ withHiddenAttributes: { attributes: { include: hiddenAttributes } } }))(target);
63
64
  };
64
65
  }
66
+ // internal functions
67
+ function getIndexName(tableName, index) {
68
+ if (index.name)
69
+ return index.name;
70
+ const fields = getIndexFields(index);
71
+ const normalizedTableName = tableName.slice(0, 5);
72
+ const normalizedFields = fields.map((field) => field.slice(0, 3));
73
+ return [normalizedTableName, ...normalizedFields].join('_');
74
+ }
75
+ function getIndexFields({ field, fields }) {
76
+ return fields ? fields.map(pangea_helpers_1.camelToSnake) : field ? [(0, pangea_helpers_1.camelToSnake)(field)] : [];
77
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.119",
4
+ "version": "3.3.120",
5
5
  "files": [
6
6
  "dist"
7
7
  ],