mirror of
https://github.com/strapi/strapi.git
synced 2025-10-29 17:04:13 +00:00
Fix relation table creation
This commit is contained in:
parent
8adc8ec200
commit
d986cb4cc8
@ -487,17 +487,38 @@ module.exports = function(strapi) {
|
||||
});
|
||||
|
||||
if (manyRelations && manyRelations.dominant) {
|
||||
const collection = manyRelations.plugin ?
|
||||
strapi.plugins[manyRelations.plugin].models[manyRelations.collection]:
|
||||
strapi.models[manyRelations.collection];
|
||||
|
||||
const attributes = {
|
||||
[`${pluralize.singular(manyRelations.collection)}_id`]: {
|
||||
type: 'integer'
|
||||
},
|
||||
[`${pluralize.singular(manyRelations.via)}_id`]: {
|
||||
[`${pluralize.singular(definition.globalId.toLowerCase())}_id`]: {
|
||||
type: 'integer'
|
||||
}
|
||||
};
|
||||
|
||||
const keys = [pluralize.plural(manyRelations.collection), pluralize.plural(manyRelations.via)];
|
||||
const table = [keys.join('_'), keys.reverse().join('_')].join('__');
|
||||
const table = _.get(manyRelations, 'collectionName') ||
|
||||
_.map(
|
||||
_.sortBy(
|
||||
[
|
||||
collection.attributes[
|
||||
manyRelations.via
|
||||
],
|
||||
manyRelations
|
||||
],
|
||||
'collection'
|
||||
),
|
||||
table => {
|
||||
return _.snakeCase(
|
||||
pluralize.plural(table.collection) +
|
||||
' ' +
|
||||
pluralize.plural(table.via)
|
||||
);
|
||||
}
|
||||
).join('__');
|
||||
|
||||
await handler(table, attributes);
|
||||
}
|
||||
|
||||
@ -1,9 +1 @@
|
||||
{
|
||||
"article": {
|
||||
"attributes": {
|
||||
"title": {
|
||||
"appearance": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{}
|
||||
Loading…
x
Reference in New Issue
Block a user