@nocobase/database 1.4.0-alpha.20241020025811 → 1.4.0-alpha.20241023053303

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.
@@ -44,6 +44,7 @@ var import_lodash = __toESM(require("lodash"));
44
44
  const _InheritedSyncRunner = class _InheritedSyncRunner {
45
45
  static async syncInheritModel(model, options) {
46
46
  const { transaction } = options;
47
+ options.hooks = options.hooks === void 0 ? true : !!options.hooks;
47
48
  const inheritedCollection = model.collection;
48
49
  const db = inheritedCollection.context.database;
49
50
  const dialect = db.sequelize.getDialect();
@@ -78,10 +79,10 @@ const _InheritedSyncRunner = class _InheritedSyncRunner {
78
79
  for (const parent of parents) {
79
80
  const sequenceNameResult = await queryInterface.sequelize.query(
80
81
  `SELECT column_default
81
- FROM information_schema.columns
82
- WHERE table_name = '${parent.model.tableName}'
83
- and table_schema = '${parent.collectionSchema()}'
84
- and "column_name" = 'id';`,
82
+ FROM information_schema.columns
83
+ WHERE table_name = '${parent.model.tableName}'
84
+ and table_schema = '${parent.collectionSchema()}'
85
+ and "column_name" = 'id';`,
85
86
  {
86
87
  transaction
87
88
  }
@@ -98,7 +99,7 @@ const _InheritedSyncRunner = class _InheritedSyncRunner {
98
99
  const sequenceName = match[1];
99
100
  const sequenceCurrentValResult = await queryInterface.sequelize.query(
100
101
  `select last_value
101
- from ${sequenceName}`,
102
+ from ${sequenceName}`,
102
103
  {
103
104
  transaction
104
105
  }
@@ -120,10 +121,10 @@ const _InheritedSyncRunner = class _InheritedSyncRunner {
120
121
  const tableName2 = sequenceTable.tableName;
121
122
  const schemaName = sequenceTable.schema;
122
123
  const idColumnSql = `SELECT column_name
123
- FROM information_schema.columns
124
- WHERE table_name = '${tableName2}'
125
- and column_name = 'id'
126
- and table_schema = '${schemaName}';
124
+ FROM information_schema.columns
125
+ WHERE table_name = '${tableName2}'
126
+ and column_name = 'id'
127
+ and table_schema = '${schemaName}';
127
128
  `;
128
129
  const idColumnQuery = await queryInterface.sequelize.query(idColumnSql, {
129
130
  transaction
@@ -133,7 +134,7 @@ const _InheritedSyncRunner = class _InheritedSyncRunner {
133
134
  }
134
135
  await queryInterface.sequelize.query(
135
136
  `alter table ${db.utils.quoteTable(sequenceTable)}
136
- alter column id set default nextval('${maxSequenceName}')`,
137
+ alter column id set default nextval('${maxSequenceName}')`,
137
138
  {
138
139
  transaction
139
140
  }
@@ -150,6 +151,13 @@ const _InheritedSyncRunner = class _InheritedSyncRunner {
150
151
  }
151
152
  }
152
153
  }
154
+ if (options.hooks) {
155
+ await model.runHooks("afterSync", {
156
+ ...options,
157
+ modelName: model.name,
158
+ transaction
159
+ });
160
+ }
153
161
  }
154
162
  static async createTable(tableName, attributes, options, model, parents) {
155
163
  let sql = "";
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.4.0-alpha.20241020025811",
3
+ "version": "1.4.0-alpha.20241023053303",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "AGPL-3.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "1.4.0-alpha.20241020025811",
10
- "@nocobase/utils": "1.4.0-alpha.20241020025811",
9
+ "@nocobase/logger": "1.4.0-alpha.20241023053303",
10
+ "@nocobase/utils": "1.4.0-alpha.20241023053303",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -38,5 +38,5 @@
38
38
  "url": "git+https://github.com/nocobase/nocobase.git",
39
39
  "directory": "packages/database"
40
40
  },
41
- "gitHead": "22c4d58a897af2661a4c0b48382ae17b1d61077e"
41
+ "gitHead": "7c6272531f271094ddac219755ac898dd33ff5ab"
42
42
  }