@abtnode/models 1.17.8-beta-20260113-015027-32a1cec4 → 1.17.8-beta-20260115-054144-b207746c

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.
Files changed (44) hide show
  1. package/lib/migrate.d.ts +1 -0
  2. package/lib/migrate.js +9 -1
  3. package/lib/migrations/blocklet/20231031000000-project.js +4 -17
  4. package/lib/migrations/blocklet/20240202000000-project.js +4 -17
  5. package/lib/migrations/blocklet/20240322000000-project-last-release.js +9 -21
  6. package/lib/migrations/blocklet/20240327000000-release-published.js +4 -17
  7. package/lib/migrations/blocklet/20240413000000-project-connected-stores.js +4 -17
  8. package/lib/migrations/blocklet/20240520000000-project-tenant-scope.js +12 -29
  9. package/lib/migrations/blocklet/20240621000000-project-upload-resource.js +4 -17
  10. package/lib/migrations/blocklet/20240724000000-projec-add-setting.js +10 -25
  11. package/lib/migrations/blocklet/20240808000000-user-phone.js +5 -10
  12. package/lib/migrations/blocklet/20240828000000-user-inviter.js +1 -1
  13. package/lib/migrations/blocklet/20241202000000-homepage.js +15 -32
  14. package/lib/migrations/blocklet/20241212000000-videos.js +5 -18
  15. package/lib/migrations/blocklet/20241216000000-notification.js +11 -15
  16. package/lib/migrations/blocklet/20241216000000-repository.js +5 -18
  17. package/lib/migrations/blocklet/20241223000000-blocklet-docker.js +10 -25
  18. package/lib/migrations/blocklet/20241224000001-notification.js +4 -8
  19. package/lib/migrations/blocklet/20241225000000-passkey.js +9 -18
  20. package/lib/migrations/blocklet/20250703000001-update-webhook-attempt-status.js +3 -2
  21. package/lib/migrations/blocklet/20250716000001-release-blocklet-introduction-length.js +5 -4
  22. package/lib/migrations/blocklet/20250718000002-change-some-colume-length.js +7 -6
  23. package/lib/migrations/blocklet/20250826000000-change-access-key-type.js +3 -2
  24. package/lib/migrations/certificate-manager/20250911000000-job-processing.js +5 -4
  25. package/lib/migrations/certificate-manager/20251224000000-job-entity-id.js +2 -2
  26. package/lib/migrations/common/20250117000000-notification-receiver.js +40 -64
  27. package/lib/migrations/common/20250211000000-notification-receiver.js +15 -39
  28. package/lib/migrations/common/20250220000000-user.js +7 -31
  29. package/lib/migrations/common/20250313000000-user.js +7 -31
  30. package/lib/migrations/common/20250319000000-notifications.js +7 -32
  31. package/lib/migrations/common/20250330000000-check-passport.js +7 -9
  32. package/lib/migrations/common/20250831000000-notifications.js +7 -32
  33. package/lib/migrations/server/20230713000000-backup.js +3 -2
  34. package/lib/migrations/server/20241216000000-notification.js +11 -15
  35. package/lib/migrations/server/20241224000001-notification.js +4 -8
  36. package/lib/migrations/server/20241225000000-passkey.js +1 -1
  37. package/lib/migrations/server/20250625000001-server-launcher.js +1 -1
  38. package/lib/migrations/server/20250704000000-upgrade-session-id.js +3 -2
  39. package/lib/migrations/server/20250718000002-change-some-colume-length.js +7 -6
  40. package/lib/migrations/server/20250826000000-change-access-key-type.js +3 -2
  41. package/lib/migrations/server/20250911000000-job-processing.js +5 -4
  42. package/lib/migrations/server/20251220000000-job-entity-id.js +2 -2
  43. package/lib/migrations/service/20250403000001-message.js +9 -28
  44. package/package.json +9 -9
@@ -37,52 +37,48 @@ const columnsToAdd = () => {
37
37
  };
38
38
  // eslint-disable-next-line import/prefer-default-export
39
39
  const up = async ({ context }) => {
40
- await context.changeColumn('notifications', 'receiver', {
40
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'receiver', {
41
41
  type: sequelize_1.DataTypes.STRING(80),
42
42
  allowNull: true, // 修改为允许空值
43
43
  });
44
- await context.changeColumn('notifications', 'action', {
44
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'action', {
45
45
  type: sequelize_1.DataTypes.STRING(255),
46
46
  allowNull: true, // 修改为允许空值
47
47
  });
48
- await context.changeColumn('notifications', 'entityType', {
48
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'entityType', {
49
49
  type: sequelize_1.DataTypes.STRING(32),
50
50
  allowNull: true, // 修改为允许空值
51
51
  });
52
- await context.changeColumn('notifications', 'entityId', {
52
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'entityId', {
53
53
  type: sequelize_1.DataTypes.STRING(80),
54
54
  allowNull: true, // 修改为允许空值
55
55
  });
56
56
  // 冗余字段
57
57
  await (0, migrate_1.removeColumnIfExists)(context, 'notifications', 'updatedAt');
58
- const tableDescriptions = await context.describeTable('notifications');
59
- const promises = [];
60
58
  for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
61
- if (!tableDescriptions[columnName]) {
62
- promises.push((0, migrate_1.addColumnIfNotExists)(context, 'notifications', columnName, columnDefinition));
63
- }
59
+ // eslint-disable-next-line no-await-in-loop
60
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notifications', columnName, columnDefinition);
64
61
  }
65
- await Promise.all(promises);
66
62
  };
67
63
  exports.up = up;
68
64
  const down = async ({ context }) => {
69
- await context.changeColumn('notifications', 'receiver', {
65
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'receiver', {
70
66
  type: sequelize_1.DataTypes.STRING(80),
71
67
  allowNull: false, // 修改为允许空值
72
68
  });
73
- await context.changeColumn('notifications', 'action', {
69
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'action', {
74
70
  type: sequelize_1.DataTypes.STRING(255),
75
71
  allowNull: false, // 修改为允许空值
76
72
  });
77
- await context.changeColumn('notifications', 'entityType', {
73
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'entityType', {
78
74
  type: sequelize_1.DataTypes.STRING(32),
79
75
  allowNull: false, // 修改为允许空值
80
76
  });
81
- await context.changeColumn('notifications', 'entityId', {
77
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'entityId', {
82
78
  type: sequelize_1.DataTypes.STRING(80),
83
79
  allowNull: false, // 修改为允许空值
84
80
  });
85
- await context.addColumn('notifications', 'updatedAt', {
81
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notifications', 'updatedAt', {
86
82
  type: sequelize_1.DataTypes.DATE,
87
83
  defaultValue: sequelize_1.DataTypes.NOW,
88
84
  });
@@ -18,22 +18,18 @@ const columnsToAdd = () => {
18
18
  };
19
19
  // eslint-disable-next-line import/prefer-default-export
20
20
  const up = async ({ context }) => {
21
- await context.changeColumn('notifications', 'description', {
21
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'description', {
22
22
  type: sequelize_1.DataTypes.TEXT,
23
23
  allowNull: true, // 修改为允许空值
24
24
  });
25
- const tableDescriptions = await context.describeTable('notifications');
26
- const promises = [];
27
25
  for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
28
- if (!tableDescriptions[columnName]) {
29
- promises.push((0, migrate_1.addColumnIfNotExists)(context, 'notifications', columnName, columnDefinition));
30
- }
26
+ // eslint-disable-next-line no-await-in-loop
27
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notifications', columnName, columnDefinition);
31
28
  }
32
- await Promise.all(promises);
33
29
  };
34
30
  exports.up = up;
35
31
  const down = async ({ context }) => {
36
- await context.changeColumn('notifications', 'description', {
32
+ await (0, migrate_1.changeColumnIfExists)(context, 'notifications', 'description', {
37
33
  type: sequelize_1.DataTypes.TEXT,
38
34
  allowNull: false,
39
35
  });
@@ -5,7 +5,7 @@ const sequelize_1 = require("sequelize");
5
5
  const migrate_1 = require("../../migrate");
6
6
  const up = async ({ context }) => {
7
7
  await (0, migrate_1.addColumnIfNotExists)(context, 'connected_accounts', 'counter', {
8
- type: sequelize_1.DataTypes.INTEGER,
8
+ type: sequelize_1.DataTypes.BIGINT,
9
9
  defaultValue: 0,
10
10
  });
11
11
  await (0, migrate_1.addColumnIfNotExists)(context, 'sessions', 'challenge', {
@@ -17,6 +17,6 @@ const up = async ({ context }) => {
17
17
  };
18
18
  exports.up = up;
19
19
  const down = async ({ context }) => {
20
- await context.removeColumn('servers', 'registerInfo');
20
+ await (0, migrate_1.removeColumnIfExists)(context, 'servers', 'registerInfo');
21
21
  };
22
22
  exports.down = down;
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.up = up;
4
4
  exports.down = down;
5
5
  const sequelize_1 = require("sequelize");
6
+ const migrate_1 = require("../../migrate");
6
7
  async function up({ context }) {
7
- await context.changeColumn('servers', 'upgradeSessionId', {
8
+ await (0, migrate_1.changeColumnIfExists)(context, 'servers', 'upgradeSessionId', {
8
9
  type: sequelize_1.DataTypes.STRING(128),
9
10
  });
10
11
  }
11
12
  async function down({ context }) {
12
- await context.changeColumn('servers', 'upgradeSessionId', {
13
+ await (0, migrate_1.changeColumnIfExists)(context, 'servers', 'upgradeSessionId', {
13
14
  type: sequelize_1.DataTypes.STRING(32),
14
15
  });
15
16
  }
@@ -3,19 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.up = up;
4
4
  exports.down = down;
5
5
  const sequelize_1 = require("sequelize");
6
+ const migrate_1 = require("../../migrate");
6
7
  async function up({ context }) {
7
8
  const dialect = context.sequelize.getDialect();
8
9
  if (dialect !== 'postgres') {
9
10
  return;
10
11
  }
11
- await context.changeColumn('audit_logs', 'ip', {
12
+ await (0, migrate_1.changeColumnIfExists)(context, 'audit_logs', 'ip', {
12
13
  type: sequelize_1.DataTypes.STRING(128),
13
14
  });
14
- await context.changeColumn('users', 'phone', {
15
+ await (0, migrate_1.changeColumnIfExists)(context, 'users', 'phone', {
15
16
  type: sequelize_1.DataTypes.STRING(64),
16
17
  allowNull: true,
17
18
  });
18
- await context.changeColumn('traffic_insights', 'date', {
19
+ await (0, migrate_1.changeColumnIfExists)(context, 'traffic_insights', 'date', {
19
20
  type: sequelize_1.DataTypes.STRING(40),
20
21
  allowNull: false,
21
22
  });
@@ -25,14 +26,14 @@ async function down({ context }) {
25
26
  if (dialect !== 'postgres') {
26
27
  return;
27
28
  }
28
- await context.changeColumn('audit_logs', 'ip', {
29
+ await (0, migrate_1.changeColumnIfExists)(context, 'audit_logs', 'ip', {
29
30
  type: sequelize_1.DataTypes.STRING(32),
30
31
  });
31
- await context.changeColumn('users', 'phone', {
32
+ await (0, migrate_1.changeColumnIfExists)(context, 'users', 'phone', {
32
33
  type: sequelize_1.DataTypes.STRING(36),
33
34
  allowNull: true,
34
35
  });
35
- await context.changeColumn('traffic_insights', 'date', {
36
+ await (0, migrate_1.changeColumnIfExists)(context, 'traffic_insights', 'date', {
36
37
  type: sequelize_1.DataTypes.STRING(10),
37
38
  allowNull: false,
38
39
  });
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.down = exports.up = void 0;
4
4
  const sequelize_1 = require("sequelize");
5
+ const migrate_1 = require("../../migrate");
5
6
  const up = async ({ context }) => {
6
- await context.changeColumn('access_keys', 'passport', {
7
+ await (0, migrate_1.changeColumnIfExists)(context, 'access_keys', 'passport', {
7
8
  type: sequelize_1.DataTypes.STRING(80),
8
9
  });
9
10
  };
10
11
  exports.up = up;
11
12
  const down = async ({ context }) => {
12
- await context.changeColumn('access_keys', 'passport', {
13
+ await (0, migrate_1.changeColumnIfExists)(context, 'access_keys', 'passport', {
13
14
  type: sequelize_1.DataTypes.STRING(16),
14
15
  });
15
16
  };
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.up = up;
4
4
  exports.down = down;
5
5
  const sequelize_1 = require("sequelize");
6
+ const migrate_1 = require("../../migrate");
6
7
  async function up({ context }) {
7
- await context.addColumn('jobs', 'processingBy', {
8
+ await (0, migrate_1.addColumnIfNotExists)(context, 'jobs', 'processingBy', {
8
9
  type: sequelize_1.DataTypes.STRING(80),
9
10
  allowNull: true,
10
11
  });
11
- await context.addColumn('jobs', 'processingAt', {
12
+ await (0, migrate_1.addColumnIfNotExists)(context, 'jobs', 'processingAt', {
12
13
  type: sequelize_1.DataTypes.BIGINT,
13
14
  allowNull: true,
14
15
  });
15
16
  }
16
17
  async function down({ context }) {
17
- await context.removeColumn('jobs', 'processingBy');
18
- await context.removeColumn('jobs', 'processingAt');
18
+ await (0, migrate_1.removeColumnIfExists)(context, 'jobs', 'processingBy');
19
+ await (0, migrate_1.removeColumnIfExists)(context, 'jobs', 'processingAt');
19
20
  }
@@ -5,12 +5,12 @@ exports.down = down;
5
5
  const sequelize_1 = require("sequelize");
6
6
  const migrate_1 = require("../../migrate");
7
7
  async function up({ context }) {
8
- await context.addColumn('jobs', 'entityId', {
8
+ await (0, migrate_1.addColumnIfNotExists)(context, 'jobs', 'entityId', {
9
9
  type: sequelize_1.DataTypes.STRING(80),
10
10
  allowNull: true,
11
11
  });
12
12
  await (0, migrate_1.safeAddIndex)(context, 'jobs', ['entityId']);
13
13
  }
14
14
  async function down({ context }) {
15
- await context.removeColumn('jobs', 'entityId');
15
+ await (0, migrate_1.removeColumnIfExists)(context, 'jobs', 'entityId');
16
16
  }
@@ -3,41 +3,22 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.down = exports.up = void 0;
5
5
  const sequelize_1 = require("sequelize");
6
- const models_1 = require("../../models");
6
+ const migrate_1 = require("../../migrate");
7
7
  const createNotificationMigration = () => ({
8
8
  up: async ({ context }) => {
9
- const transaction = await context.sequelize.transaction();
10
- try {
11
- if (!(await (0, models_1.existsColumn)(context, 'messages', 'expiredAt'))) {
12
- await context.addColumn('messages', 'expiredAt', {
13
- type: sequelize_1.DataTypes.DATE,
14
- allowNull: true,
15
- }, { transaction });
16
- await context.addIndex('messages', ['expiredAt'], {
17
- name: 'messages_expiredAt_index',
18
- transaction,
19
- });
20
- }
21
- await transaction.commit();
22
- }
23
- catch (error) {
24
- await transaction.rollback();
25
- throw error;
26
- }
9
+ await (0, migrate_1.addColumnIfNotExists)(context, 'messages', 'expiredAt', {
10
+ type: sequelize_1.DataTypes.DATE,
11
+ allowNull: true,
12
+ });
13
+ await (0, migrate_1.safeAddIndex)(context, 'messages', ['expiredAt'], { name: 'messages_expiredAt_index' });
27
14
  },
28
15
  down: async ({ context }) => {
29
- const transaction = await context.sequelize.transaction();
16
+ await (0, migrate_1.removeColumnIfExists)(context, 'messages', 'expiredAt');
30
17
  try {
31
- if (await (0, models_1.existsColumn)(context, 'messages', 'expiredAt')) {
32
- await context.removeColumn('messages', 'expiredAt', { transaction });
33
- await context.removeIndex('messages', 'messages_expiredAt_index', { transaction });
34
- }
35
- await transaction.commit();
18
+ await context.removeIndex('messages', 'messages_expiredAt_index');
36
19
  }
37
20
  catch (error) {
38
- await transaction.rollback();
39
- console.error('Migration rollback failed:', error);
40
- throw error;
21
+ // Index may not exist
41
22
  }
42
23
  },
43
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/models",
3
- "version": "1.17.8-beta-20260113-015027-32a1cec4",
3
+ "version": "1.17.8-beta-20260115-054144-b207746c",
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,13 +33,13 @@
33
33
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@abtnode/constant": "1.17.8-beta-20260113-015027-32a1cec4",
37
- "@abtnode/db-cache": "1.17.8-beta-20260113-015027-32a1cec4",
38
- "@abtnode/logger": "1.17.8-beta-20260113-015027-32a1cec4",
39
- "@abtnode/types": "1.17.8-beta-20260113-015027-32a1cec4",
40
- "@abtnode/util": "1.17.8-beta-20260113-015027-32a1cec4",
41
- "@arcblock/did": "^1.28.4",
42
- "@arcblock/validator": "^1.28.4",
36
+ "@abtnode/constant": "1.17.8-beta-20260115-054144-b207746c",
37
+ "@abtnode/db-cache": "1.17.8-beta-20260115-054144-b207746c",
38
+ "@abtnode/logger": "1.17.8-beta-20260115-054144-b207746c",
39
+ "@abtnode/types": "1.17.8-beta-20260115-054144-b207746c",
40
+ "@abtnode/util": "1.17.8-beta-20260115-054144-b207746c",
41
+ "@arcblock/did": "^1.28.5",
42
+ "@arcblock/validator": "^1.28.5",
43
43
  "lodash.clonedeep": "^4.5.0",
44
44
  "lodash.isempty": "^4.4.0",
45
45
  "pg": "^8.16.3",
@@ -57,5 +57,5 @@
57
57
  "@typescript/native-preview": "^7.0.0-dev.20251230.1"
58
58
  },
59
59
  "resolutions": {},
60
- "gitHead": "a2bdf6146c5c94d7348fc87d5ebd2e95e548df07"
60
+ "gitHead": "41ed680ba394b4a0fb1db898b6e64f6cfee4ac5c"
61
61
  }