Skip Navigation

[Resolved] Relationship migration problem – no merge allowed

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 10 replies, has 2 voices.

Last updated by Nigel 5 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#1247073

I have run the relationship migration on one of our sites, and there now seems to be a problem. We were using relationship to assign authors (post type 'people') to different kinds of content ('articles', 'publications', 'videos' etc.). Under the old structure there was the intermediate post type 'authorships') that managed these relationships.

However, the migrated relationships we now have a one:many relationship for each post type and a single one:many relationship for people.

In the back end of the post type the new temporary post type appears and I can't assign people as before. However, in the front end the existing assigned authors are still displaying correctly.

When I try to merge these, as per https://toolset.com/documentation/post-relationships/how-to-merge-existing-post-relationships/ the relationships are all greyed out as soon as I select merge.

Stuck... how do we move forward with this?

#1247089

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Ian

I think the best thing would be if you could provide me with a copy of the site pre-migration that I can use as a starting point and go through the migration process myself.

Can you provide such a duplicate?

hidden link

I'll mark your next reply as private for you to share the URL if available.

#1247111

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry, I was expecting a duplicator installer file and archive package (two files).

Are you able to provide those?

#1247113

Hi Nigel - sorry, we're using Updraft Plus instead of Duplicator - but if you uncompress those zip files it's extremely straightforward - it's just the database and the plugin folders, together with any extra files needed to get the site up. If you re-install the database you'll have everything you need.

#1247173

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I tried importing the database to a fresh site after doing a text replace for the table prefix but the import failed. I've tried a couple of times with different errors each time. I'll try again tomorrow.

#1247691

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm still unable to complete importing the sql file to recreate the database.

Could I get credentials for your site, it will be much quicker for me to install a plugin to take a snapshot and it will avoid me introducing any inconsistencies between your version of the site and a version that I manually reconstruct.

#1248019

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Ian

I installed a copy and examined the relationships and I can see why merging them is not—and will not be—possible.

You were using one post type to act as an intermediary post type for several different relationships when you set this up.

So authorships is the intermediate post type for the people-articles relationship, and the people-publications relationship, and... etc.

In Types 3 M2M relationships cannot share the same intermediate post type, each relationship requires a unique intermediate post type where relevant.

You can see this if you edit your relationships and you deactivate all but the people-authorship and article-authorship relationships (go as if to delete them and you'll see an option to de-activate them instead).

With just those two relationships active you *can* then merge them. But you would then need to manually create new people-videos etc. relationships, and there is no mechanism for then automatically migrating the data.

If you want to migrate to Types 3 relationships, identify which relationship you should merge to save you the most amount of data you'll have to fix.

#1248061

Thanks Nigel

I suspected this may be the case. Is there any way to get around this? Perhaps by creating new relationship post types and copying the tables over?

best,

#1248117

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You would need to write a script to manually migrate the relationship data yourself.

Ignore the existing (migrated) relationships for a moment.

Make new relationships as required, so an M2M relationship between people and articles, an M2M relationship between people and publications, etc.

Write a script to loop through the people posts and for each one get the related authorship posts and for each of those get the related articles and use toolset_connect_posts to make a connection using the new people - articles relationship, get the related publications and use toolset_connect_posts to make a connection using the new people - publications relationship, etc.

Once you've run that (the code snippets feature at Toolset > Settings > Custom Code helpfully lets you run code one time only) then you can delete the old migrated relationships and then make any changes to the forms or Views that use data from related posts so that they operate with the new relationships.

See this page for the relevant API documentation (you would be using toolset_get_related_posts and toolset_connect_posts): https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

#1251125

Thanks Nigel - will follow up on this and post here about how it goes. best, Ian

#1255005

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Ian

I'm just updating the status to awaiting feedback from you so it's not sitting in my queue. Let me know how you get on.