@abtnode/models 1.17.8-beta-20260113-015027-32a1cec4 → 1.17.8-beta-20260115-003043-5e15c08a

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
@@ -3,15 +3,16 @@ 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
  // 之前是枚举,现在改成字符串
8
- await context.changeColumn('webhook_attempts', 'status', {
9
+ await (0, migrate_1.changeColumnIfExists)(context, 'webhook_attempts', 'status', {
9
10
  type: sequelize_1.DataTypes.STRING(80),
10
11
  allowNull: false,
11
12
  });
12
13
  }
13
14
  async function down({ context }) {
14
- await context.changeColumn('webhook_attempts', 'status', {
15
+ await (0, migrate_1.changeColumnIfExists)(context, 'webhook_attempts', 'status', {
15
16
  type: sequelize_1.DataTypes.STRING(80),
16
17
  allowNull: false,
17
18
  });
@@ -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
- await context.changeColumn('releases', 'blockletIntroduction', {
8
+ await (0, migrate_1.changeColumnIfExists)(context, 'releases', 'blockletIntroduction', {
8
9
  type: sequelize_1.DataTypes.STRING(3000),
9
10
  });
10
- await context.changeColumn('projects', 'blockletIntroduction', {
11
+ await (0, migrate_1.changeColumnIfExists)(context, 'projects', 'blockletIntroduction', {
11
12
  type: sequelize_1.DataTypes.STRING(3000),
12
13
  });
13
14
  }
14
15
  async function down({ context }) {
15
- await context.changeColumn('releases', 'blockletIntroduction', {
16
+ await (0, migrate_1.changeColumnIfExists)(context, 'releases', 'blockletIntroduction', {
16
17
  type: sequelize_1.DataTypes.STRING(255),
17
18
  });
18
- await context.changeColumn('projects', 'blockletIntroduction', {
19
+ await (0, migrate_1.changeColumnIfExists)(context, 'projects', 'blockletIntroduction', {
19
20
  type: sequelize_1.DataTypes.STRING(255),
20
21
  });
21
22
  }
@@ -3,20 +3,21 @@ 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('users', 'phone', {
12
+ await (0, migrate_1.changeColumnIfExists)(context, 'users', 'phone', {
12
13
  type: sequelize_1.DataTypes.STRING(64),
13
14
  allowNull: true,
14
15
  });
15
- await context.changeColumn('verify_codes', 'code', {
16
+ await (0, migrate_1.changeColumnIfExists)(context, 'verify_codes', 'code', {
16
17
  type: sequelize_1.DataTypes.STRING(32),
17
18
  allowNull: false,
18
19
  });
19
- await context.changeColumn('user_sessions', 'ua', {
20
+ await (0, migrate_1.changeColumnIfExists)(context, 'user_sessions', 'ua', {
20
21
  type: sequelize_1.DataTypes.STRING(1024),
21
22
  });
22
23
  }
@@ -25,15 +26,15 @@ async function down({ context }) {
25
26
  if (dialect !== 'postgres') {
26
27
  return;
27
28
  }
28
- await context.changeColumn('users', 'phone', {
29
+ await (0, migrate_1.changeColumnIfExists)(context, 'users', 'phone', {
29
30
  type: sequelize_1.DataTypes.STRING(36),
30
31
  allowNull: true,
31
32
  });
32
- await context.changeColumn('verify_codes', 'code', {
33
+ await (0, migrate_1.changeColumnIfExists)(context, 'verify_codes', 'code', {
33
34
  type: sequelize_1.DataTypes.STRING(8),
34
35
  allowNull: false,
35
36
  });
36
- await context.changeColumn('user_sessions', 'ua', {
37
+ await (0, migrate_1.changeColumnIfExists)(context, 'user_sessions', 'ua', {
37
38
  type: sequelize_1.DataTypes.STRING(512),
38
39
  });
39
40
  }
@@ -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
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const sequelize_1 = require("sequelize");
4
+ const migrate_1 = require("../../migrate");
4
5
  const util_1 = require("../../util");
5
6
  const columnsToAdd = () => {
6
7
  return {
@@ -36,73 +37,48 @@ const columnsToAdd = () => {
36
37
  };
37
38
  const createNotificationReceiversMigration = () => ({
38
39
  up: async ({ context }) => {
39
- const transaction = await context.sequelize.transaction();
40
- const tableDescriptions = await context.describeTable('notification_receivers');
41
- try {
42
- await context.changeColumn('notification_receivers', 'walletSendStatus', {
43
- type: sequelize_1.DataTypes.INTEGER,
44
- defaultValue: 0,
45
- validate: {
46
- isIn: [[0, 1, 2]],
47
- },
48
- }, { transaction });
49
- await context.changeColumn('notification_receivers', 'pushKitSendStatus', {
50
- type: sequelize_1.DataTypes.INTEGER,
51
- defaultValue: 0,
52
- validate: {
53
- isIn: [[0, 1, 2]],
54
- },
55
- }, { transaction });
56
- await context.changeColumn('notification_receivers', 'emailSendStatus', {
57
- type: sequelize_1.DataTypes.INTEGER,
58
- defaultValue: 0,
59
- validate: {
60
- isIn: [[0, 1, 2]],
61
- },
62
- }, { transaction });
63
- const promises = [];
64
- for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
65
- if (!tableDescriptions[columnName]) {
66
- promises.push(context.addColumn('notification_receivers', columnName, columnDefinition, { transaction }));
67
- }
68
- }
69
- await Promise.all(promises);
70
- await transaction.commit();
71
- }
72
- catch (error) {
73
- await transaction.rollback();
74
- throw error;
40
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'walletSendStatus', {
41
+ type: sequelize_1.DataTypes.INTEGER,
42
+ defaultValue: 0,
43
+ validate: {
44
+ isIn: [[0, 1, 2]],
45
+ },
46
+ });
47
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'pushKitSendStatus', {
48
+ type: sequelize_1.DataTypes.INTEGER,
49
+ defaultValue: 0,
50
+ validate: {
51
+ isIn: [[0, 1, 2]],
52
+ },
53
+ });
54
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'emailSendStatus', {
55
+ type: sequelize_1.DataTypes.INTEGER,
56
+ defaultValue: 0,
57
+ validate: {
58
+ isIn: [[0, 1, 2]],
59
+ },
60
+ });
61
+ for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
62
+ // eslint-disable-next-line no-await-in-loop
63
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notification_receivers', columnName, columnDefinition);
75
64
  }
76
65
  },
77
66
  down: async ({ context }) => {
78
- const transaction = await context.sequelize.transaction();
79
- const tableDescriptions = await context.describeTable('notification_receivers');
80
- try {
81
- await context.changeColumn('notification_receivers', 'walletSendStatus', {
82
- type: sequelize_1.DataTypes.SMALLINT,
83
- defaultValue: 0,
84
- }, { transaction });
85
- await context.changeColumn('notification_receivers', 'pushKitSendStatus', {
86
- type: sequelize_1.DataTypes.SMALLINT,
87
- defaultValue: 0,
88
- }, { transaction });
89
- await context.changeColumn('notification_receivers', 'emailSendStatus', {
90
- type: sequelize_1.DataTypes.SMALLINT,
91
- defaultValue: 0,
92
- }, { transaction });
93
- const promises = [];
94
- for (const [columnName] of Object.entries(columnsToAdd())) {
95
- if (tableDescriptions[columnName]) {
96
- promises.push(context.removeColumn('notification_receivers', columnName, { transaction }));
97
- }
98
- }
99
- await Promise.all(promises);
100
- await transaction.commit();
101
- }
102
- catch (error) {
103
- await transaction.rollback();
104
- console.error('Migration rollback failed:', error);
105
- throw error;
67
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'walletSendStatus', {
68
+ type: sequelize_1.DataTypes.SMALLINT,
69
+ defaultValue: 0,
70
+ });
71
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'pushKitSendStatus', {
72
+ type: sequelize_1.DataTypes.SMALLINT,
73
+ defaultValue: 0,
74
+ });
75
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'emailSendStatus', {
76
+ type: sequelize_1.DataTypes.SMALLINT,
77
+ defaultValue: 0,
78
+ });
79
+ for (const [columnName] of Object.entries(columnsToAdd())) {
80
+ // eslint-disable-next-line no-await-in-loop
81
+ await (0, migrate_1.removeColumnIfExists)(context, 'notification_receivers', columnName);
106
82
  }
107
83
  },
108
84
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const sequelize_1 = require("sequelize");
4
+ const migrate_1 = require("../../migrate");
4
5
  const util_1 = require("../../util");
5
6
  const columnsToAdd = () => {
6
7
  return {
@@ -20,48 +21,23 @@ const columnsToAdd = () => {
20
21
  };
21
22
  const createNotificationReceiversMigration = () => ({
22
23
  up: async ({ context }) => {
23
- const tableDescriptions = await context.describeTable('notification_receivers');
24
- const transaction = await context.sequelize.transaction();
25
- try {
26
- await context.changeColumn('notification_receivers', 'webhook', {
27
- type: (0, util_1.JSONOrJSONB)(),
28
- defaultValue: {},
29
- }, { transaction });
30
- const promises = [];
31
- for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
32
- if (!tableDescriptions[columnName]) {
33
- promises.push(context.addColumn('notification_receivers', columnName, columnDefinition, { transaction }));
34
- }
35
- }
36
- await Promise.all(promises);
37
- await transaction.commit();
38
- }
39
- catch (error) {
40
- await transaction.rollback();
41
- throw error;
24
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'webhook', {
25
+ type: (0, util_1.JSONOrJSONB)(),
26
+ defaultValue: {},
27
+ });
28
+ for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
29
+ // eslint-disable-next-line no-await-in-loop
30
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notification_receivers', columnName, columnDefinition);
42
31
  }
43
32
  },
44
33
  down: async ({ context }) => {
45
- const transaction = await context.sequelize.transaction();
46
- const tableDescriptions = await context.describeTable('notification_receivers');
47
- try {
48
- await context.changeColumn('notification_receivers', 'webhook', {
49
- type: (0, util_1.JSONOrJSONB)(),
50
- defaultValue: [],
51
- }, { transaction });
52
- const promises = [];
53
- for (const [columnName] of Object.entries(columnsToAdd())) {
54
- if (tableDescriptions[columnName]) {
55
- promises.push(context.removeColumn('notification_receivers', columnName, { transaction }));
56
- }
57
- }
58
- await Promise.all(promises);
59
- await transaction.commit();
60
- }
61
- catch (error) {
62
- await transaction.rollback();
63
- console.error('Migration rollback failed:', error);
64
- throw error;
34
+ await (0, migrate_1.changeColumnIfExists)(context, 'notification_receivers', 'webhook', {
35
+ type: (0, util_1.JSONOrJSONB)(),
36
+ defaultValue: [],
37
+ });
38
+ for (const [columnName] of Object.entries(columnsToAdd())) {
39
+ // eslint-disable-next-line no-await-in-loop
40
+ await (0, migrate_1.removeColumnIfExists)(context, 'notification_receivers', columnName);
65
41
  }
66
42
  },
67
43
  });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const migrate_1 = require("../../migrate");
3
4
  const util_1 = require("../../util");
4
5
  const columnsToAdd = () => {
5
6
  return {
@@ -11,40 +12,15 @@ const columnsToAdd = () => {
11
12
  };
12
13
  const createUserMigration = () => ({
13
14
  up: async ({ context }) => {
14
- const tableDescriptions = await context.describeTable('users');
15
- const transaction = await context.sequelize.transaction();
16
- try {
17
- const promises = [];
18
- for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
19
- if (!tableDescriptions[columnName]) {
20
- promises.push(context.addColumn('users', columnName, columnDefinition, { transaction }));
21
- }
22
- }
23
- await Promise.all(promises);
24
- await transaction.commit();
25
- }
26
- catch (error) {
27
- await transaction.rollback();
28
- throw error;
15
+ for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
16
+ // eslint-disable-next-line no-await-in-loop
17
+ await (0, migrate_1.addColumnIfNotExists)(context, 'users', columnName, columnDefinition);
29
18
  }
30
19
  },
31
20
  down: async ({ context }) => {
32
- const tableDescriptions = await context.describeTable('users');
33
- const transaction = await context.sequelize.transaction();
34
- try {
35
- const promises = [];
36
- for (const [columnName] of Object.entries(columnsToAdd())) {
37
- if (tableDescriptions[columnName]) {
38
- promises.push(context.removeColumn('users', columnName, { transaction }));
39
- }
40
- }
41
- await Promise.all(promises);
42
- await transaction.commit();
43
- }
44
- catch (error) {
45
- await transaction.rollback();
46
- console.error('Migration rollback failed:', error);
47
- throw error;
21
+ for (const [columnName] of Object.entries(columnsToAdd())) {
22
+ // eslint-disable-next-line no-await-in-loop
23
+ await (0, migrate_1.removeColumnIfExists)(context, 'users', columnName);
48
24
  }
49
25
  },
50
26
  });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const migrate_1 = require("../../migrate");
3
4
  const util_1 = require("../../util");
4
5
  const columnsToAdd = () => {
5
6
  return {
@@ -11,40 +12,15 @@ const columnsToAdd = () => {
11
12
  };
12
13
  const createUserMigration = () => ({
13
14
  up: async ({ context }) => {
14
- const transaction = await context.sequelize.transaction();
15
- try {
16
- const tableDescriptions = await context.describeTable('users');
17
- const promises = [];
18
- for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
19
- if (!tableDescriptions[columnName]) {
20
- promises.push(context.addColumn('users', columnName, columnDefinition, { transaction }));
21
- }
22
- }
23
- await Promise.all(promises);
24
- await transaction.commit();
25
- }
26
- catch (error) {
27
- await transaction.rollback();
28
- throw error;
15
+ for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
16
+ // eslint-disable-next-line no-await-in-loop
17
+ await (0, migrate_1.addColumnIfNotExists)(context, 'users', columnName, columnDefinition);
29
18
  }
30
19
  },
31
20
  down: async ({ context }) => {
32
- const tableDescriptions = await context.describeTable('users');
33
- const transaction = await context.sequelize.transaction();
34
- try {
35
- const promises = [];
36
- for (const [columnName] of Object.entries(columnsToAdd())) {
37
- if (tableDescriptions[columnName]) {
38
- promises.push(context.removeColumn('users', columnName, { transaction }));
39
- }
40
- }
41
- await Promise.all(promises);
42
- await transaction.commit();
43
- }
44
- catch (error) {
45
- await transaction.rollback();
46
- console.error('Migration rollback failed:', error);
47
- throw error;
21
+ for (const [columnName] of Object.entries(columnsToAdd())) {
22
+ // eslint-disable-next-line no-await-in-loop
23
+ await (0, migrate_1.removeColumnIfExists)(context, 'users', columnName);
48
24
  }
49
25
  },
50
26
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const models_1 = require("../../models");
3
+ const migrate_1 = require("../../migrate");
4
4
  const util_1 = require("../../util");
5
5
  const columnsToAdd = () => {
6
6
  return {
@@ -12,40 +12,15 @@ const columnsToAdd = () => {
12
12
  };
13
13
  const createNotificationMigration = () => ({
14
14
  up: async ({ context }) => {
15
- const transaction = await context.sequelize.transaction();
16
- try {
17
- const promises = [];
18
- for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
19
- // eslint-disable-next-line no-await-in-loop
20
- if (!(await (0, models_1.existsColumn)(context, 'notifications', columnName))) {
21
- promises.push(context.addColumn('notifications', columnName, columnDefinition, { transaction }));
22
- }
23
- }
24
- await Promise.all(promises);
25
- await transaction.commit();
26
- }
27
- catch (error) {
28
- await transaction.rollback();
29
- throw error;
15
+ for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
16
+ // eslint-disable-next-line no-await-in-loop
17
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notifications', columnName, columnDefinition);
30
18
  }
31
19
  },
32
20
  down: async ({ context }) => {
33
- const transaction = await context.sequelize.transaction();
34
- try {
35
- const promises = [];
36
- for (const [columnName] of Object.entries(columnsToAdd())) {
37
- // eslint-disable-next-line no-await-in-loop
38
- if (await (0, models_1.existsColumn)(context, 'notifications', columnName)) {
39
- promises.push(context.removeColumn('notifications', columnName, { transaction }));
40
- }
41
- }
42
- await Promise.all(promises);
43
- await transaction.commit();
44
- }
45
- catch (error) {
46
- await transaction.rollback();
47
- console.error('Migration rollback failed:', error);
48
- throw error;
21
+ for (const [columnName] of Object.entries(columnsToAdd())) {
22
+ // eslint-disable-next-line no-await-in-loop
23
+ await (0, migrate_1.removeColumnIfExists)(context, 'notifications', columnName);
49
24
  }
50
25
  },
51
26
  });
@@ -2,14 +2,12 @@
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
- const passportColumns = await context.describeTable('passports');
7
- if (!passportColumns.parentDid) {
8
- await context.addColumn('passports', 'parentDid', { type: sequelize_1.DataTypes.STRING(80), allowNull: true });
9
- }
10
- if (!passportColumns.source) {
11
- await context.addColumn('passports', 'source', { type: sequelize_1.DataTypes.ENUM('invite', 'recover', 'trusted', 'issue') });
12
- }
7
+ await (0, migrate_1.addColumnIfNotExists)(context, 'passports', 'parentDid', { type: sequelize_1.DataTypes.STRING(80), allowNull: true });
8
+ await (0, migrate_1.addColumnIfNotExists)(context, 'passports', 'source', {
9
+ type: sequelize_1.DataTypes.ENUM('invite', 'recover', 'trusted', 'issue'),
10
+ });
13
11
  const indexes = [
14
12
  { fields: ['passportId'], name: 'passport_logs_passport_id' },
15
13
  { fields: ['action'], name: 'passport_logs_action' },
@@ -31,8 +29,8 @@ const up = async ({ context }) => {
31
29
  };
32
30
  exports.up = up;
33
31
  const down = async ({ context }) => {
34
- await context.removeColumn('passports', 'parentDid');
35
- await context.removeColumn('passports', 'source');
32
+ await (0, migrate_1.removeColumnIfExists)(context, 'passports', 'parentDid');
33
+ await (0, migrate_1.removeColumnIfExists)(context, 'passports', 'source');
36
34
  const indexNames = ['passport_logs_passport_id', 'passport_logs_action', 'passport_logs_operator_did'];
37
35
  const tableIndexes = await context.showIndex('passport_logs');
38
36
  const existingIndexNames = Object.values(tableIndexes).map((index) => index.name);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const models_1 = require("../../models");
3
+ const migrate_1 = require("../../migrate");
4
4
  const util_1 = require("../../util");
5
5
  const columnsToAdd = () => {
6
6
  return {
@@ -12,40 +12,15 @@ const columnsToAdd = () => {
12
12
  };
13
13
  const createNotificationMigration = () => ({
14
14
  up: async ({ context }) => {
15
- const transaction = await context.sequelize.transaction();
16
- try {
17
- const promises = [];
18
- for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
19
- // eslint-disable-next-line no-await-in-loop
20
- if (!(await (0, models_1.existsColumn)(context, 'notifications', columnName))) {
21
- promises.push(context.addColumn('notifications', columnName, columnDefinition, { transaction }));
22
- }
23
- }
24
- await Promise.all(promises);
25
- await transaction.commit();
26
- }
27
- catch (error) {
28
- await transaction.rollback();
29
- throw error;
15
+ for (const [columnName, columnDefinition] of Object.entries(columnsToAdd())) {
16
+ // eslint-disable-next-line no-await-in-loop
17
+ await (0, migrate_1.addColumnIfNotExists)(context, 'notifications', columnName, columnDefinition);
30
18
  }
31
19
  },
32
20
  down: async ({ context }) => {
33
- const transaction = await context.sequelize.transaction();
34
- try {
35
- const promises = [];
36
- for (const [columnName] of Object.entries(columnsToAdd())) {
37
- // eslint-disable-next-line no-await-in-loop
38
- if (await (0, models_1.existsColumn)(context, 'notifications', columnName)) {
39
- promises.push(context.removeColumn('notifications', columnName, { transaction }));
40
- }
41
- }
42
- await Promise.all(promises);
43
- await transaction.commit();
44
- }
45
- catch (error) {
46
- await transaction.rollback();
47
- console.error('Migration rollback failed:', error);
48
- throw error;
21
+ for (const [columnName] of Object.entries(columnsToAdd())) {
22
+ // eslint-disable-next-line no-await-in-loop
23
+ await (0, migrate_1.removeColumnIfExists)(context, 'notifications', columnName);
49
24
  }
50
25
  },
51
26
  });
@@ -2,15 +2,16 @@
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('backups', 'updatedAt', {
7
+ await (0, migrate_1.changeColumnIfExists)(context, 'backups', 'updatedAt', {
7
8
  type: sequelize_1.DataTypes.DATE,
8
9
  defaultValue: null,
9
10
  });
10
11
  };
11
12
  exports.up = up;
12
13
  const down = async ({ context }) => {
13
- await context.changeColumn('backups', 'updatedAt', {
14
+ await (0, migrate_1.changeColumnIfExists)(context, 'backups', 'updatedAt', {
14
15
  type: sequelize_1.DataTypes.DATE,
15
16
  defaultValue: sequelize_1.DataTypes.NOW,
16
17
  });