fix: SequelizeForeignKeyConstraintError: insert or update on table "actions_scopes" violates foreign key constraint "actions_scopes_collection_name_fkey"
This commit is contained in:
parent
1d8de0bc4e
commit
f1c0503916
@ -73,6 +73,18 @@ const defaultValues = {
|
||||
default: true,
|
||||
},
|
||||
],
|
||||
scopes: [
|
||||
{
|
||||
title: '全部数据',
|
||||
filter: {},
|
||||
},
|
||||
{
|
||||
title: '用户自己的数据',
|
||||
filter: {
|
||||
"created_by_id.$currentUser": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default async function (model: CollectionModel, options: any = {}) {
|
||||
|
@ -55,12 +55,12 @@ export class Permissions {
|
||||
// const s = await model.createScope(scope, options);
|
||||
// console.log(s.toJSON());
|
||||
// }
|
||||
try {
|
||||
await Scope.bulkCreate(defaultScopes.map(scope => ({...scope, collection_name: model.get('name')})));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
// try {
|
||||
// await Scope.bulkCreate(defaultScopes.map(scope => ({...scope, collection_name: model.get('name')})));
|
||||
// } catch (error) {
|
||||
// console.error(error);
|
||||
// throw error;
|
||||
// }
|
||||
});
|
||||
|
||||
database.getModel('users').addHook('afterCreate', async(model, options) => {
|
||||
|
Loading…
Reference in New Issue
Block a user