From c4b819528a15f3f7294ce4027ea64342742881f3 Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 26 Aug 2024 18:42:59 +0800 Subject: [PATCH] fix: missing schema --- .../20240802141435-collection-tree.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-collection-tree/src/server/migrations/20240802141435-collection-tree.ts b/packages/plugins/@nocobase/plugin-collection-tree/src/server/migrations/20240802141435-collection-tree.ts index 371e22af9d..480ed9651c 100644 --- a/packages/plugins/@nocobase/plugin-collection-tree/src/server/migrations/20240802141435-collection-tree.ts +++ b/packages/plugins/@nocobase/plugin-collection-tree/src/server/migrations/20240802141435-collection-tree.ts @@ -28,9 +28,8 @@ export default class extends Migration { for (const treeCollection of treeCollections) { const name = `main_${treeCollection.name}_path`; - this.app.db.collection({ + const collectionOptions = { name, - schema: treeCollection.options.schema, autoGenId: false, timestamps: false, fields: [ @@ -43,20 +42,27 @@ export default class extends Migration { fields: [{ name: 'path', length: 191 }], }, ], - }); + }; + if (treeCollection.options.schema) { + collectionOptions['schema'] = treeCollection.options.schema; + } + this.app.db.collection(collectionOptions); const treeExistsInDb = await this.app.db.getCollection(name).existsInDb({ transaction }); if (!treeExistsInDb) { await this.app.db.getCollection(name).sync({ transaction } as SyncOptions); - this.app.db.collection({ + const opts = { name: treeCollection.name, - schema: treeCollection.options.schema, autoGenId: false, timestamps: false, fields: [ { type: 'integer', name: 'id' }, { type: 'integer', name: 'parentId' }, ], - }); + }; + if (treeCollection.options.schema) { + opts['schema'] = treeCollection.options.schema; + } + this.app.db.collection(opts); const chunkSize = 1000; await this.app.db.getRepository(treeCollection.name).chunk({ chunkSize: chunkSize,