@abtnode/models 1.16.31-beta-52250475 → 1.16.31-beta-a0cc72cf

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.
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('users', 'inviter', {
7
+ type: sequelize_1.DataTypes.STRING(40),
8
+ allowNull: true,
9
+ });
10
+ };
11
+ exports.up = up;
12
+ const down = async ({ context }) => {
13
+ await context.removeColumn('users', 'inviter');
14
+ };
15
+ exports.down = down;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('users', 'generation', {
7
+ type: sequelize_1.DataTypes.SMALLINT,
8
+ defaultValue: 0,
9
+ });
10
+ await context.sequelize.query('UPDATE users SET generation=0');
11
+ };
12
+ exports.up = up;
13
+ const down = async ({ context }) => {
14
+ await context.removeColumn('users', 'generation');
15
+ };
16
+ exports.down = down;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const up = async ({ context }) => {
5
+ try {
6
+ await context.addIndex('users', ['lastLoginAt']);
7
+ await context.addIndex('users', ['inviter']);
8
+ await context.addIndex('tagging', ['taggableType', 'taggableId']);
9
+ await context.addIndex('user_sessions', ['userDid', 'status']);
10
+ await context.addIndex('notifications', ['createdAt']);
11
+ await context.addIndex('permissions', ['type', 'createdAt']);
12
+ await context.addIndex('projects', ['createdAt']);
13
+ await context.addIndex('projects', ['createdBy']);
14
+ await context.addIndex('projects', ['createdBy', 'createdAt']);
15
+ await context.addIndex('releases', ['createdAt']);
16
+ await context.addIndex('releases', ['projectId']);
17
+ await context.addIndex('releases', ['projectId', 'createdAt']);
18
+ }
19
+ catch (err) {
20
+ console.error('Failed to add blocklet indexes', err);
21
+ }
22
+ };
23
+ exports.up = up;
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ const down = async ({ context }) => { };
26
+ exports.down = down;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('users', 'inviter', {
7
+ type: sequelize_1.DataTypes.STRING(40),
8
+ allowNull: true,
9
+ });
10
+ };
11
+ exports.up = up;
12
+ const down = async ({ context }) => {
13
+ await context.removeColumn('users', 'inviter');
14
+ };
15
+ exports.down = down;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('users', 'generation', {
7
+ type: sequelize_1.DataTypes.SMALLINT,
8
+ defaultValue: 0,
9
+ });
10
+ await context.sequelize.query('UPDATE users SET generation=0');
11
+ };
12
+ exports.up = up;
13
+ const down = async ({ context }) => {
14
+ await context.removeColumn('users', 'generation');
15
+ };
16
+ exports.down = down;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const up = async ({ context }) => {
5
+ try {
6
+ await context.addIndex('blocklets', ['createdAt']);
7
+ await context.addIndex('blocklets', ['structV1Did']);
8
+ await context.addIndex('sites', ['domain']);
9
+ await context.addIndex('users', ['lastLoginAt']);
10
+ await context.addIndex('users', ['inviter']);
11
+ await context.addIndex('tagging', ['taggableType', 'taggableId']);
12
+ await context.addIndex('audit_logs', ['scope', 'createdAt']);
13
+ await context.addIndex('audit_logs', ['createdAt']);
14
+ await context.addIndex('backups', ['appPid', 'createdAt']);
15
+ await context.addIndex('notifications', ['createdAt']);
16
+ await context.addIndex('permissions', ['type', 'createdAt']);
17
+ await context.sequelize.query("CREATE INDEX blocklets_meta_did ON `blocklets` ((json_extract(`meta`, '$.did')));");
18
+ }
19
+ catch (err) {
20
+ console.error('Failed to add server indexes', err);
21
+ }
22
+ };
23
+ exports.up = up;
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ const down = async ({ context }) => { };
26
+ exports.down = down;
@@ -82,10 +82,12 @@ __exportStar(require("./traffic-insight"), exports);
82
82
  __exportStar(require("./runtime-insight"), exports);
83
83
  __exportStar(require("./tag"), exports);
84
84
  __exportStar(require("./tagging"), exports);
85
+ const logEnabled = !process.env.DISABLE_SQLITE_LOG &&
86
+ (process.env.DEBUG === '@abtnode/models' || ['production', 'test'].includes(process.env.NODE_ENV) === false);
85
87
  const instances = new Map();
86
88
  function createSequelize(dbPath, config = {
87
- logging: !process.env.DISABLE_SQLITE_LOG &&
88
- (process.env.DEBUG === '@abtnode/models' || ['production', 'test'].includes(process.env.NODE_ENV) === false),
89
+ benchmark: logEnabled,
90
+ logging: logEnabled,
89
91
  }) {
90
92
  if (instances.has(dbPath)) {
91
93
  return instances.get(dbPath);
@@ -25,6 +25,14 @@ function createUserModel() {
25
25
  type: sequelize_1.DataTypes.STRING(36),
26
26
  allowNull: true,
27
27
  },
28
+ inviter: {
29
+ type: sequelize_1.DataTypes.STRING(40),
30
+ allowNull: true,
31
+ },
32
+ generation: {
33
+ type: sequelize_1.DataTypes.SMALLINT,
34
+ defaultValue: 0,
35
+ },
28
36
  }, {
29
37
  sequelize,
30
38
  modelName: 'User',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/models",
3
- "version": "1.16.31-beta-52250475",
3
+ "version": "1.16.31-beta-a0cc72cf",
4
4
  "description": "Sequelize models for blocklet server and blocklet service",
5
5
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
6
6
  "publishConfig": {
@@ -33,8 +33,8 @@
33
33
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@abtnode/logger": "1.16.31-beta-52250475",
37
- "@abtnode/types": "1.16.31-beta-52250475",
36
+ "@abtnode/logger": "1.16.31-beta-a0cc72cf",
37
+ "@abtnode/types": "1.16.31-beta-a0cc72cf",
38
38
  "lodash.clonedeep": "^4.5.0",
39
39
  "lodash.isempty": "^4.4.0",
40
40
  "sequelize": "^6.35.0",
@@ -54,5 +54,5 @@
54
54
  "typescript": "^5.0.4"
55
55
  },
56
56
  "resolutions": {},
57
- "gitHead": "26155b86f103f9e64fd8a23b7fffdb279c71209c"
57
+ "gitHead": "d1eec814979a4086fc5efd7c719687b76c972ec6"
58
58
  }