@abtnode/models 1.16.29-beta-2eaf40bc → 1.16.29-beta-cbfd116d

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,21 @@
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 models_1 = require("../../models");
6
+ const up = async ({ context }) => {
7
+ if (!(await (0, models_1.existsColumn)(context, 'users', 'url'))) {
8
+ await context.addColumn('users', 'url', {
9
+ type: sequelize_1.DataTypes.STRING,
10
+ allowNull: true,
11
+ defaultValue: '',
12
+ });
13
+ }
14
+ };
15
+ exports.up = up;
16
+ const down = async ({ context }) => {
17
+ if (await (0, models_1.existsColumn)(context, 'users', 'url')) {
18
+ await context.removeColumn('users', 'url');
19
+ }
20
+ };
21
+ exports.down = down;
@@ -0,0 +1,21 @@
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 models_1 = require("../../models");
6
+ const up = async ({ context }) => {
7
+ if (!(await (0, models_1.existsColumn)(context, 'users', 'url'))) {
8
+ await context.addColumn('users', 'url', {
9
+ type: sequelize_1.DataTypes.STRING,
10
+ allowNull: true,
11
+ defaultValue: '',
12
+ });
13
+ }
14
+ };
15
+ exports.up = up;
16
+ const down = async ({ context }) => {
17
+ if (await (0, models_1.existsColumn)(context, 'users', 'url')) {
18
+ await context.removeColumn('users', 'url');
19
+ }
20
+ };
21
+ exports.down = down;
@@ -1,4 +1,5 @@
1
- import { Sequelize } from 'sequelize';
1
+ import { Sequelize, type QueryInterface } from 'sequelize';
2
+ import { LiteralUnion } from 'type-fest';
2
3
  export * from './message';
3
4
  export * from './account';
4
5
  export * from './certificate';
@@ -80,3 +81,5 @@ export declare function getConnectModels(): {
80
81
  ConnectionV2: import("../types").DynamicModel<import("./connection-v2").ConnectionV2State>;
81
82
  };
82
83
  export declare function setupModels(models: any, sequelize: Sequelize): void;
84
+ type TableName = LiteralUnion<'users', string>;
85
+ export declare function existsColumn(context: QueryInterface, tableName: TableName, columnName: string): Promise<boolean>;
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.setupModels = exports.getConnectModels = exports.getServerModels = exports.getBlockletModels = exports.getCertificateManagerModels = exports.getServiceModels = exports.destroySequelize = exports.createSequelize = void 0;
17
+ exports.existsColumn = exports.setupModels = exports.getConnectModels = exports.getServerModels = exports.getBlockletModels = exports.getCertificateManagerModels = exports.getServiceModels = exports.destroySequelize = exports.createSequelize = void 0;
18
18
  const sequelize_1 = require("sequelize");
19
19
  const message_1 = require("./message");
20
20
  const account_1 = require("./account");
@@ -88,6 +88,9 @@ function createSequelize(dbPath, config = {
88
88
  }
89
89
  else {
90
90
  sequelize = new sequelize_1.Sequelize({ dialect: 'sqlite', storage: dbPath, ...config });
91
+ sequelize.query('pragma journal_mode = WAL;');
92
+ sequelize.query('pragma synchronous = normal;');
93
+ sequelize.query('pragma journal_size_limit = 67108864;');
91
94
  }
92
95
  instances.set(dbPath, sequelize);
93
96
  return instances.get(dbPath);
@@ -181,3 +184,8 @@ function setupModels(models, sequelize) {
181
184
  });
182
185
  }
183
186
  exports.setupModels = setupModels;
187
+ async function existsColumn(context, tableName, columnName) {
188
+ const columnsDescription = await context.describeTable(tableName);
189
+ return columnName in columnsDescription;
190
+ }
191
+ exports.existsColumn = existsColumn;
@@ -16,6 +16,11 @@ function createUserModel() {
16
16
  type: sequelize_1.DataTypes.JSON,
17
17
  allowNull: true,
18
18
  },
19
+ url: {
20
+ type: sequelize_1.DataTypes.STRING,
21
+ allowNull: true,
22
+ defaultValue: '',
23
+ },
19
24
  }, {
20
25
  sequelize,
21
26
  modelName: 'User',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/models",
3
- "version": "1.16.29-beta-2eaf40bc",
3
+ "version": "1.16.29-beta-cbfd116d",
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,12 +33,13 @@
33
33
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@abtnode/logger": "1.16.29-beta-2eaf40bc",
37
- "@abtnode/types": "1.16.29-beta-2eaf40bc",
36
+ "@abtnode/logger": "1.16.29-beta-cbfd116d",
37
+ "@abtnode/types": "1.16.29-beta-cbfd116d",
38
38
  "lodash.clonedeep": "^4.5.0",
39
39
  "lodash.isempty": "^4.4.0",
40
40
  "sequelize": "^6.35.0",
41
41
  "sqlite3": "^5.1.7",
42
+ "type-fest": "^4.21.0",
42
43
  "umzug": "3.4.0",
43
44
  "uuid": "^9.0.1"
44
45
  },
@@ -53,5 +54,5 @@
53
54
  "typescript": "^5.0.4"
54
55
  },
55
56
  "resolutions": {},
56
- "gitHead": "d723d07ca8914468fc1b53af23aa53dc343e0a8c"
57
+ "gitHead": "e9bdb7af77f2d126e40195c67972b07fe683adf9"
57
58
  }