@nocobase/plugin-data-source-main 1.2.12-alpha → 1.3.0-alpha.20240710084543

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 (88) hide show
  1. package/package.json +2 -2
  2. package/dist/client/index.d.ts +0 -13
  3. package/dist/client/index.js +0 -10
  4. package/dist/externalVersion.js +0 -21
  5. package/dist/index.d.ts +0 -10
  6. package/dist/index.js +0 -48
  7. package/dist/locale/en-US.json +0 -3
  8. package/dist/locale/zh-CN.json +0 -3
  9. package/dist/server/collections/collectionCategories.d.ts +0 -11
  10. package/dist/server/collections/collectionCategories.js +0 -61
  11. package/dist/server/collections/collections.d.ts +0 -11
  12. package/dist/server/collections/collections.js +0 -101
  13. package/dist/server/collections/fields.d.ts +0 -11
  14. package/dist/server/collections/fields.js +0 -103
  15. package/dist/server/errors/field-name-exists-error.d.ts +0 -13
  16. package/dist/server/errors/field-name-exists-error.js +0 -45
  17. package/dist/server/hooks/afterCreateForForeignKeyField.d.ts +0 -10
  18. package/dist/server/hooks/afterCreateForForeignKeyField.js +0 -217
  19. package/dist/server/hooks/afterCreateForReverseField.d.ts +0 -12
  20. package/dist/server/hooks/afterCreateForReverseField.js +0 -46
  21. package/dist/server/hooks/afterDestroyForForeignKeyField.d.ts +0 -10
  22. package/dist/server/hooks/afterDestroyForForeignKeyField.js +0 -98
  23. package/dist/server/hooks/beforeCreateForChildrenCollection.d.ts +0 -13
  24. package/dist/server/hooks/beforeCreateForChildrenCollection.js +0 -67
  25. package/dist/server/hooks/beforeCreateForReverseField.d.ts +0 -12
  26. package/dist/server/hooks/beforeCreateForReverseField.js +0 -73
  27. package/dist/server/hooks/beforeCreateForValidateField.d.ts +0 -15
  28. package/dist/server/hooks/beforeCreateForValidateField.js +0 -76
  29. package/dist/server/hooks/beforeCreateForViewCollection.d.ts +0 -13
  30. package/dist/server/hooks/beforeCreateForViewCollection.js +0 -39
  31. package/dist/server/hooks/beforeDestroyForeignKey.d.ts +0 -10
  32. package/dist/server/hooks/beforeDestroyForeignKey.js +0 -75
  33. package/dist/server/hooks/beforeInitOptions.d.ts +0 -23
  34. package/dist/server/hooks/beforeInitOptions.js +0 -137
  35. package/dist/server/hooks/index.d.ts +0 -13
  36. package/dist/server/hooks/index.js +0 -38
  37. package/dist/server/index.d.ts +0 -12
  38. package/dist/server/index.js +0 -54
  39. package/dist/server/migrations/20220613103214-alert-sub-table.d.ts +0 -13
  40. package/dist/server/migrations/20220613103214-alert-sub-table.js +0 -50
  41. package/dist/server/migrations/20220704225714-drop-foreign-keys.d.ts +0 -13
  42. package/dist/server/migrations/20220704225714-drop-foreign-keys.js +0 -79
  43. package/dist/server/migrations/20221101111110-update-foreign-fields.d.ts +0 -13
  44. package/dist/server/migrations/20221101111110-update-foreign-fields.js +0 -74
  45. package/dist/server/migrations/20221104151410-update-collections-hidden.d.ts +0 -13
  46. package/dist/server/migrations/20221104151410-update-collections-hidden.js +0 -57
  47. package/dist/server/migrations/20221121111110-update-fk-type.d.ts +0 -13
  48. package/dist/server/migrations/20221121111110-update-fk-type.js +0 -155
  49. package/dist/server/migrations/20221121111113-update-id-to-bigint.d.ts +0 -13
  50. package/dist/server/migrations/20221121111113-update-id-to-bigint.js +0 -189
  51. package/dist/server/migrations/20221221103220-timestamps.d.ts +0 -13
  52. package/dist/server/migrations/20221221103220-timestamps.js +0 -55
  53. package/dist/server/migrations/20230225111112-drop-ui-schema-relation.d.ts +0 -13
  54. package/dist/server/migrations/20230225111112-drop-ui-schema-relation.js +0 -97
  55. package/dist/server/migrations/20230509111114-alert-ui-schema.d.ts +0 -13
  56. package/dist/server/migrations/20230509111114-alert-ui-schema.js +0 -87
  57. package/dist/server/migrations/20230623145414-number-step.d.ts +0 -13
  58. package/dist/server/migrations/20230623145414-number-step.js +0 -81
  59. package/dist/server/migrations/20230704222935-tableoid.d.ts +0 -13
  60. package/dist/server/migrations/20230704222935-tableoid.js +0 -83
  61. package/dist/server/migrations/20230918024546-set-collection-schema.d.ts +0 -13
  62. package/dist/server/migrations/20230918024546-set-collection-schema.js +0 -55
  63. package/dist/server/migrations/20240220153103-install-main-datasource.d.ts +0 -14
  64. package/dist/server/migrations/20240220153103-install-main-datasource.js +0 -51
  65. package/dist/server/migrations/20240419182147-fix-created-by-field-target.d.ts +0 -14
  66. package/dist/server/migrations/20240419182147-fix-created-by-field-target.js +0 -49
  67. package/dist/server/migrations/20240420105949-add-sort-field.d.ts +0 -14
  68. package/dist/server/migrations/20240420105949-add-sort-field.js +0 -81
  69. package/dist/server/migrations/20240517101001-fix-target-option-in-tree-collection.d.ts +0 -14
  70. package/dist/server/migrations/20240517101001-fix-target-option-in-tree-collection.js +0 -54
  71. package/dist/server/models/collection.d.ts +0 -27
  72. package/dist/server/models/collection.js +0 -194
  73. package/dist/server/models/field.d.ts +0 -26
  74. package/dist/server/models/field.js +0 -173
  75. package/dist/server/models/index.d.ts +0 -10
  76. package/dist/server/models/index.js +0 -32
  77. package/dist/server/repositories/collection-repository.d.ts +0 -20
  78. package/dist/server/repositories/collection-repository.js +0 -169
  79. package/dist/server/repositories/index.d.ts +0 -9
  80. package/dist/server/repositories/index.js +0 -30
  81. package/dist/server/resourcers/collections.d.ts +0 -12
  82. package/dist/server/resourcers/collections.js +0 -102
  83. package/dist/server/resourcers/views.d.ts +0 -17
  84. package/dist/server/resourcers/views.js +0 -116
  85. package/dist/server/server.d.ts +0 -19
  86. package/dist/server/server.js +0 -384
  87. package/dist/swagger/index.d.ts +0 -413
  88. package/dist/swagger/index.js +0 -440
@@ -1,57 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var update_collections_hidden_exports = {};
28
- __export(update_collections_hidden_exports, {
29
- default: () => UpdateCollectionsHiddenMigration
30
- });
31
- module.exports = __toCommonJS(update_collections_hidden_exports);
32
- var import_server = require("@nocobase/server");
33
- /* istanbul ignore file -- @preserve */
34
- class UpdateCollectionsHiddenMigration extends import_server.Migration {
35
- appVersion = "<0.8.0-alpha.11";
36
- async up() {
37
- const result = await this.app.version.satisfies("<=0.8.0-alpha.9");
38
- if (!result) {
39
- return;
40
- }
41
- try {
42
- await this.app.db.getRepository("collections").update({
43
- filter: {
44
- options: {
45
- autoCreate: true,
46
- isThrough: true
47
- }
48
- },
49
- values: {
50
- hidden: true
51
- }
52
- });
53
- } catch (error) {
54
- console.error(error);
55
- }
56
- }
57
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Migration } from '@nocobase/server';
10
- export default class UpdateIdToBigIntMigrator extends Migration {
11
- appVersion: string;
12
- up(): Promise<void>;
13
- }
@@ -1,155 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var update_fk_type_exports = {};
28
- __export(update_fk_type_exports, {
29
- default: () => UpdateIdToBigIntMigrator
30
- });
31
- module.exports = __toCommonJS(update_fk_type_exports);
32
- var import_database = require("@nocobase/database");
33
- var import_server = require("@nocobase/server");
34
- /* istanbul ignore file -- @preserve */
35
- class UpdateIdToBigIntMigrator extends import_server.Migration {
36
- appVersion = "<0.8.1-alpha.2";
37
- async up() {
38
- const result = await this.app.version.satisfies("<0.9.0-alpha.1");
39
- if (!result) {
40
- return;
41
- }
42
- const db = this.app.db;
43
- await db.getCollection("fields").repository.update({
44
- filter: {
45
- name: "id",
46
- type: "integer"
47
- },
48
- values: {
49
- type: "bigInt"
50
- }
51
- });
52
- if (!db.inDialect("mysql", "mariadb", "postgres")) {
53
- return;
54
- }
55
- const models = [];
56
- const queryInterface = db.sequelize.getQueryInterface();
57
- const queryGenerator = queryInterface.queryGenerator;
58
- const updateToBigInt = async (model, fieldName) => {
59
- let sql;
60
- const tableName = model.tableName;
61
- if (model.rawAttributes[fieldName].type instanceof import_database.DataTypes.INTEGER) {
62
- if (db.inDialect("postgres")) {
63
- sql = `ALTER TABLE "${tableName}"
64
- ALTER COLUMN "${fieldName}" SET DATA TYPE BIGINT;`;
65
- } else if (db.inDialect("mysql", "mariadb")) {
66
- const dataTypeOrOptions = model.rawAttributes[fieldName];
67
- const attributeName = fieldName;
68
- const query = queryGenerator.attributesToSQL(
69
- {
70
- [attributeName]: queryInterface.normalizeAttribute({
71
- ...dataTypeOrOptions,
72
- type: import_database.DataTypes.BIGINT
73
- })
74
- },
75
- {
76
- context: "changeColumn",
77
- table: tableName
78
- }
79
- );
80
- sql = queryGenerator.changeColumnQuery(tableName, query);
81
- sql = sql.replace(" PRIMARY KEY;", " ;");
82
- }
83
- try {
84
- await this.sequelize.query(sql, {});
85
- } catch (err) {
86
- if (err.message.includes("does not exist")) {
87
- return;
88
- }
89
- throw err;
90
- }
91
- this.app.log.info(`updated ${tableName}.${fieldName} to BIGINT`, { tableName, fieldName });
92
- }
93
- };
94
- this.app.db.sequelize.modelManager.forEachModel((model) => {
95
- models.push(model);
96
- });
97
- for (const model of models) {
98
- try {
99
- const primaryKeyField = model.tableAttributes[model.primaryKeyField];
100
- const collection = db.modelCollection.get(model);
101
- if (!collection) {
102
- continue;
103
- }
104
- if (primaryKeyField && primaryKeyField.primaryKey) {
105
- await updateToBigInt(model, model.primaryKeyField);
106
- }
107
- if (model.tableAttributes["sort"] && model.tableAttributes["sort"].type instanceof import_database.DataTypes.INTEGER) {
108
- await updateToBigInt(model, "sort");
109
- }
110
- const associations = model.associations;
111
- for (const associationName of Object.keys(associations)) {
112
- const association = associations[associationName];
113
- const type = association.associationType;
114
- let foreignModel;
115
- let fieldName;
116
- if (type === "BelongsTo") {
117
- foreignModel = association.source;
118
- fieldName = association.foreignKey;
119
- }
120
- if (type === "HasMany") {
121
- foreignModel = association.target;
122
- fieldName = association.foreignKey;
123
- }
124
- if (type === "HasOne") {
125
- foreignModel = association.target;
126
- fieldName = association.foreignKey;
127
- }
128
- if (foreignModel && fieldName) {
129
- const cf = await db.getRepository("collections.fields", foreignModel.name).findOne({
130
- filterByTk: fieldName
131
- });
132
- if (cf) {
133
- cf.interface = "integer";
134
- cf.type = "bigInt";
135
- await cf.save();
136
- }
137
- await updateToBigInt(foreignModel, fieldName);
138
- }
139
- if (type === "BelongsToMany") {
140
- const throughModel = association.through.model;
141
- const otherKey = association.otherKey;
142
- const foreignKey = association.foreignKey;
143
- await updateToBigInt(throughModel, otherKey);
144
- await updateToBigInt(throughModel, foreignKey);
145
- }
146
- }
147
- } catch (error) {
148
- if (error.message.includes("cannot alter inherited column")) {
149
- continue;
150
- }
151
- throw error;
152
- }
153
- }
154
- }
155
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Migration } from '@nocobase/server';
10
- export default class UpdateIdToBigIntMigrator extends Migration {
11
- appVersion: string;
12
- up(): Promise<void>;
13
- }
@@ -1,189 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var update_id_to_bigint_exports = {};
28
- __export(update_id_to_bigint_exports, {
29
- default: () => UpdateIdToBigIntMigrator
30
- });
31
- module.exports = __toCommonJS(update_id_to_bigint_exports);
32
- var import_database = require("@nocobase/database");
33
- var import_server = require("@nocobase/server");
34
- /* istanbul ignore file -- @preserve */
35
- class UpdateIdToBigIntMigrator extends import_server.Migration {
36
- appVersion = "<0.8.1-alpha.2";
37
- async up() {
38
- const result = await this.app.version.satisfies("<0.9.0-alpha.1");
39
- if (!result) {
40
- return;
41
- }
42
- const db = this.app.db;
43
- await db.getCollection("fields").repository.update({
44
- filter: {
45
- $or: [
46
- {
47
- name: "id",
48
- type: "integer"
49
- }
50
- ]
51
- },
52
- values: {
53
- type: "bigInt"
54
- }
55
- });
56
- if (!db.inDialect("mysql", "mariadb", "postgres")) {
57
- return;
58
- }
59
- const models = [];
60
- const queryInterface = db.sequelize.getQueryInterface();
61
- const queryGenerator = queryInterface.queryGenerator;
62
- const updateToBigInt = async (model, fieldName) => {
63
- const columnName = model.rawAttributes[fieldName].field;
64
- let sql;
65
- const tableName = model.tableName;
66
- const addSchemaTableName = db.utils.addSchema(tableName);
67
- const quoteTableName = db.utils.quoteTable(addSchemaTableName);
68
- const collection = db.modelCollection.get(model);
69
- const fieldRecord = await db.getCollection("fields").repository.findOne({
70
- filter: {
71
- collectionName: collection.name,
72
- name: fieldName,
73
- type: "integer"
74
- }
75
- });
76
- if (fieldRecord) {
77
- fieldRecord.set("type", "bigInt");
78
- await fieldRecord.save();
79
- }
80
- if (model.rawAttributes[fieldName].type instanceof import_database.DataTypes.INTEGER) {
81
- if (db.inDialect("postgres")) {
82
- sql = `ALTER TABLE ${quoteTableName}
83
- ALTER COLUMN "${columnName}" SET DATA TYPE BIGINT;`;
84
- } else if (db.inDialect("mysql", "mariadb")) {
85
- const dataTypeOrOptions = model.rawAttributes[fieldName];
86
- const attributeName = fieldName;
87
- const query = queryGenerator.attributesToSQL(
88
- {
89
- [attributeName]: queryInterface.normalizeAttribute({
90
- ...dataTypeOrOptions,
91
- type: import_database.DataTypes.BIGINT
92
- })
93
- },
94
- {
95
- context: "changeColumn",
96
- table: tableName
97
- }
98
- );
99
- sql = queryGenerator.changeColumnQuery(addSchemaTableName, query);
100
- sql = sql.replace(" PRIMARY KEY;", " ;");
101
- }
102
- try {
103
- await this.sequelize.query(sql, {});
104
- } catch (err) {
105
- if (err.message.includes("does not exist") || err.message.includes("cannot alter inherited column")) {
106
- return;
107
- }
108
- throw err;
109
- }
110
- if (db.inDialect("postgres")) {
111
- const sequenceQuery = `SELECT pg_get_serial_sequence('${quoteTableName}', '${columnName}');`;
112
- const [result2] = await this.sequelize.query(sequenceQuery, {});
113
- const sequenceName = result2[0]["pg_get_serial_sequence"];
114
- if (sequenceName) {
115
- await this.sequelize.query(`ALTER SEQUENCE ${sequenceName} AS BIGINT;`, {});
116
- }
117
- }
118
- this.app.log.info(`updated ${tableName}.${fieldName} to BIGINT`, { tableName, fieldName });
119
- }
120
- };
121
- const singleForeignFields = await db.getCollection("fields").repository.find({
122
- filter: {
123
- options: {
124
- isForeignKey: true
125
- },
126
- type: "integer"
127
- }
128
- });
129
- for (const field of singleForeignFields) {
130
- const collection = db.getCollection(field.get("collectionName"));
131
- if (!collection) {
132
- console.log("collection not found", field.get("collectionName"));
133
- }
134
- await updateToBigInt(collection.model, field.get("name"));
135
- }
136
- this.app.db.sequelize.modelManager.forEachModel((model) => {
137
- models.push(model);
138
- });
139
- for (const model of models) {
140
- try {
141
- const primaryKeyField = model.tableAttributes[model.primaryKeyField];
142
- const collection = db.modelCollection.get(model);
143
- if (!collection) {
144
- continue;
145
- }
146
- if (primaryKeyField && primaryKeyField.primaryKey) {
147
- await updateToBigInt(model, model.primaryKeyField);
148
- }
149
- if (model.tableAttributes["sort"] && model.tableAttributes["sort"].type instanceof import_database.DataTypes.INTEGER) {
150
- await updateToBigInt(model, "sort");
151
- }
152
- const associations = model.associations;
153
- for (const associationName of Object.keys(associations)) {
154
- const association = associations[associationName];
155
- const type = association.associationType;
156
- let foreignModel;
157
- let fieldName;
158
- if (type === "BelongsTo") {
159
- foreignModel = association.source;
160
- fieldName = association.foreignKey;
161
- }
162
- if (type === "HasMany") {
163
- foreignModel = association.target;
164
- fieldName = association.foreignKey;
165
- }
166
- if (type === "HasOne") {
167
- foreignModel = association.target;
168
- fieldName = association.foreignKey;
169
- }
170
- if (foreignModel && fieldName) {
171
- await updateToBigInt(foreignModel, fieldName);
172
- }
173
- if (type === "BelongsToMany") {
174
- const throughModel = association.through.model;
175
- const otherKey = association.otherKey;
176
- const foreignKey = association.foreignKey;
177
- await updateToBigInt(throughModel, otherKey);
178
- await updateToBigInt(throughModel, foreignKey);
179
- }
180
- }
181
- } catch (error) {
182
- if (error.message.includes("cannot alter inherited column")) {
183
- continue;
184
- }
185
- throw error;
186
- }
187
- }
188
- }
189
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Migration } from '@nocobase/server';
10
- export default class extends Migration {
11
- appVersion: string;
12
- up(): Promise<void>;
13
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var timestamps_exports = {};
28
- __export(timestamps_exports, {
29
- default: () => timestamps_default
30
- });
31
- module.exports = __toCommonJS(timestamps_exports);
32
- var import_server = require("@nocobase/server");
33
- /* istanbul ignore file -- @preserve */
34
- class timestamps_default extends import_server.Migration {
35
- appVersion = "<0.8.1-alpha.2";
36
- async up() {
37
- const result = await this.app.version.satisfies("<=0.8.0-alpha.14");
38
- if (!result) {
39
- return;
40
- }
41
- try {
42
- const collections = await this.app.db.getRepository("collections").find();
43
- console.log("migrating...");
44
- for (const collection of collections) {
45
- if (collection.get("autoCreate") && collection.get("isThrough")) {
46
- collection.set("timestamps", true);
47
- await collection.save();
48
- console.log(`collection name: ${collection.name}`);
49
- }
50
- }
51
- } catch (error) {
52
- console.error(error);
53
- }
54
- }
55
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Migration } from '@nocobase/server';
10
- export default class extends Migration {
11
- appVersion: string;
12
- up(): Promise<void>;
13
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var drop_ui_schema_relation_exports = {};
28
- __export(drop_ui_schema_relation_exports, {
29
- default: () => drop_ui_schema_relation_default
30
- });
31
- module.exports = __toCommonJS(drop_ui_schema_relation_exports);
32
- var import_server = require("@nocobase/server");
33
- /* istanbul ignore file -- @preserve */
34
- class drop_ui_schema_relation_default extends import_server.Migration {
35
- appVersion = "<0.9.2-alpha.1";
36
- async up() {
37
- const result = await this.app.version.satisfies("<0.9.2-alpha.2");
38
- if (!result) {
39
- return;
40
- }
41
- const transaction = await this.db.sequelize.transaction();
42
- const migrateFieldsSchema = async (collection) => {
43
- this.app.log.info(`Start to migrate ${collection.name} collection's ui schema`);
44
- const field = collection.setField("uiSchemaUid", {
45
- type: "string"
46
- });
47
- const exists = await field.existsInDb({ transaction });
48
- if (!exists) {
49
- collection.removeField("uiSchemaUid");
50
- return;
51
- }
52
- const fieldRecords = await collection.repository.find({
53
- transaction
54
- });
55
- const fieldsCount = await collection.repository.count({
56
- transaction
57
- });
58
- this.app.log.info(`Total ${fieldsCount} fields need to be migrated`);
59
- let i = 0;
60
- for (const fieldRecord of fieldRecords) {
61
- i++;
62
- this.app.log.info(
63
- `Migrate field ${fieldRecord.get("collectionName")}.${fieldRecord.get("name")}, ${i}/${fieldsCount}`
64
- );
65
- const uiSchemaUid = fieldRecord.get("uiSchemaUid");
66
- if (!uiSchemaUid) {
67
- continue;
68
- }
69
- const uiSchemaRecord = await this.db.getRepository("uiSchemas").findOne({
70
- filterByTk: uiSchemaUid,
71
- transaction
72
- });
73
- if (!uiSchemaRecord) {
74
- continue;
75
- }
76
- const uiSchema = uiSchemaRecord.get("schema");
77
- fieldRecord.set("uiSchema", uiSchema);
78
- await fieldRecord.save({
79
- transaction
80
- });
81
- }
82
- collection.removeField("uiSchemaUid");
83
- this.app.log.info("Migrate uiSchema to options field done");
84
- };
85
- try {
86
- await migrateFieldsSchema(this.db.getCollection("fields"));
87
- if (this.db.getCollection("fieldsHistory")) {
88
- await migrateFieldsSchema(this.db.getCollection("fieldsHistory"));
89
- }
90
- await transaction.commit();
91
- } catch (error) {
92
- await transaction.rollback();
93
- this.app.log.error(error);
94
- throw error;
95
- }
96
- }
97
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import { Migration } from '@nocobase/server';
10
- export default class extends Migration {
11
- appVersion: string;
12
- up(): Promise<void>;
13
- }