mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:25:52 +00:00
fix(tree): missing collection schema (#5131)
This commit is contained in:
parent
da966813ee
commit
1a85719657
@ -7,10 +7,10 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { Migration } from '@nocobase/server';
|
||||
import { Model, SyncOptions } from '@nocobase/database';
|
||||
import { Transaction } from 'sequelize';
|
||||
import { Migration } from '@nocobase/server';
|
||||
import lodash from 'lodash';
|
||||
import { Transaction } from 'sequelize';
|
||||
|
||||
export default class extends Migration {
|
||||
on = 'afterLoad'; // 'beforeLoad' or 'afterLoad'
|
||||
@ -30,6 +30,7 @@ export default class extends Migration {
|
||||
const name = `main_${treeCollection.name}_path`;
|
||||
this.app.db.collection({
|
||||
name,
|
||||
schema: treeCollection.options.schema,
|
||||
autoGenId: false,
|
||||
timestamps: false,
|
||||
fields: [
|
||||
@ -48,6 +49,7 @@ export default class extends Migration {
|
||||
await this.app.db.getCollection(name).sync({ transaction } as SyncOptions);
|
||||
this.app.db.collection({
|
||||
name: treeCollection.name,
|
||||
schema: treeCollection.options.schema,
|
||||
autoGenId: false,
|
||||
timestamps: false,
|
||||
fields: [
|
||||
|
@ -7,11 +7,11 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { Plugin } from '@nocobase/server';
|
||||
import { Collection, Model, SyncOptions, DestroyOptions } from '@nocobase/database';
|
||||
import { DataSource, SequelizeCollectionManager } from '@nocobase/data-source-manager';
|
||||
import { Transaction } from 'sequelize';
|
||||
import { Collection, DestroyOptions, Model, SyncOptions } from '@nocobase/database';
|
||||
import { Plugin } from '@nocobase/server';
|
||||
import lodash from 'lodash';
|
||||
import { Transaction } from 'sequelize';
|
||||
import { TreeCollection } from './tree-collection';
|
||||
|
||||
const getFilterTargetKey = (model: Model) => {
|
||||
@ -40,7 +40,11 @@ class PluginCollectionTreeServer extends Plugin {
|
||||
const parentForeignKey = collection.treeParentField?.foreignKey || 'parentId';
|
||||
|
||||
//always define tree path collection
|
||||
this.defineTreePathCollection(name);
|
||||
const options = {};
|
||||
if (collection.options.schema) {
|
||||
options['schema'] = collection.options.schema;
|
||||
}
|
||||
this.defineTreePathCollection(name, options);
|
||||
|
||||
//afterSync
|
||||
collectionManager.db.on(`${collection.name}.afterSync`, async ({ transaction }) => {
|
||||
@ -134,7 +138,7 @@ class PluginCollectionTreeServer extends Plugin {
|
||||
});
|
||||
}
|
||||
|
||||
private async defineTreePathCollection(name: string) {
|
||||
private async defineTreePathCollection(name: string, options: { schema?: string }) {
|
||||
this.db.collection({
|
||||
name,
|
||||
autoGenId: false,
|
||||
@ -149,6 +153,7 @@ class PluginCollectionTreeServer extends Plugin {
|
||||
fields: [{ name: 'path', length: 191 }],
|
||||
},
|
||||
],
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user