import { visit } from '@takeshape/util';
import get from 'lodash/get.js';
const migrate = async (_, projectSchema) => {
    visit(projectSchema, ['@relationship'], (relationship, path) => {
        const parent = get(projectSchema, path.slice(0, -1));
        parent['@backreference'] = { enabled: true };
        if (relationship.relatedName) {
            parent['@backreference'].name = relationship.relatedName;
            relationship.relatedName = undefined;
        }
    });
    return {
        ...projectSchema,
        schemaVersion: '3.13.0'
    };
};
export default migrate;
