When/If to Migrate Relationships in Old Toolset Sites
Yesterday, we released a major update for Toolset with new post relationships. In this post we explain in what cases, and if at all, you should migrate existing sites to use the new schema.
The new post relationship feature in Types 3.0 allows you to build one-to-one, one-to-many, and many-to-many relationships. It’s integrated with all of the Toolset plugins. This means that your relationships will appear in Views, you can choose related fields and build forms for related content.
The previous relationships stored connections in postmeta (custom fields). This new relationship stores connections in a dedicated table.
What are the possibilities for existing sites?
Types 3.0 includes a migration tool which will set-up the new relationships, based on the old relationships. It will copy all the setup data and all the actual connections. The purpose of this migration tool is to allow you to use the new relationship features on sites that you built before this development became available.
When you update Types to version 3.0, go to the Toolset -> Relationships page and you’ll see the following migration prompt.
You can run the migration or dismiss it. Running the migration can take a while because it needs to process all the posts that were previously related and connect them again through the new connections table. For example, on our own Toolset.com site, it took 2 hours to run (and it ran without problems).
Should I migrate?
For old sites that you already delivered and are working, there’s no real need to run this migration. The sites will continue working as before with the old relationships. Users will be able to keep connecting posts with the old schema. Of course, you will not get the new features, but chances are you don’t need the new features for projects that you already completed.
If you want to improve existing sites, this migration is for you. Previously, to implement many-to-many relationships, you had to go through intermediary posts. It works but was heavy on the CPU and database. The new relationships allow you to implement many-to-many connections conveniently and with little server load.
However, you’ll need to spend a bit of work to adjust your code to take advantage of the new relationships.
How to migrate
First, please make a copy of your site’s database. We’ve made many tests and the migration tool worked for us. It worked for us on all our production sites, as well as test sites. But, it’s a long and complex process and it may fail. So, please prepare a backup before you run it.
Go to the Toolset -> Relationships page and click the Run the migration button.
A dialog will appear, with some warnings and checks. Review and confirm all of them and start the migration.
You’ll see the migration tool working and working and working. When it’s done, you’ll get a summary of everything that it did.
After you’ve run the migration, the Toolset -> Relationships page will reload. It will display a list of all relationships and allow you to manage them. You’ll see the ones you previously created and you can create new ones.
What about new sites?
New sites that you build with Types 3.0 (or with its betas) already use the new relationships schema. There’s nothing to migrate, so you’re all set.
If you have any questions, doubts or concerns, ask here and we’ll get back to you.