Upgrading Taxonomies from 0.9 to 1.4 with data intact.

Oct 1, 2012 at 1:04 PM


Has anyone done this? We're trying to move to Orchard 1.5 and upgrading the taxonomies module is proving to be a show stopper. We have a couple of thousand content items all with various terms selected and the new version of the taxonomies module seems to have changed the database structure.

Currently working on a SQL script to migrate our data but hoping there might be something out there already.

Even an explanation of how the structure changes map across would save us time puzzling it out.



Oct 1, 2012 at 1:10 PM

So, just seen this issue http://orchardtaxonomies.codeplex.com/workitem/55 which I guess answer my question of whether there's anything out there already.

So I guess all I can hope for is a bit of explanation of whether there is a logical mapping between the old and new table structures to help me write my SQL.

Or am I stuffed? :)



Oct 1, 2012 at 2:46 PM
Edited Oct 1, 2012 at 2:48 PM

Managed to write a script for this so no worries. For anyone trying to do the same as me:

  1. Script a create data from Contrib_Taxonomies_TermContentItem. Save it in a safe place.
  2. Delete all data from Contrib_Taxonomies_TermContentItem.
  3. Change the column name ‘ContentItemRecord_Id’ to ‘TermsPartRecord_id’
  4. Insert it back again from the script you saved, using a find and replace to alter the above column names
  5. Insert a row into Contrib_Taxonomies_TermsPartRecord for all Id's in the TermsPartRecord_id column of the previous table.
  6. Run this script to remove any duplicates (you might not have to do this, depending on your existing data quality).

DECLARE TermsCursor CURSOR FOR SELECT Id, Field, TermRecord_Id, TermsPartRecord_Id FROM Contrib_Taxonomies_TermContentItem
OPEN TermsCursor

DECLARE @CurrentTermId INT
DECLARE @CurrentTermsPartId INT

FETCH NEXT FROM TermsCursor INTO @CurrentId, @CurrentField, @CurrentTermId, @CurrentTermsPartId

 DELETE FROM Contrib_Taxonomies_TermContentItem
WHERE Id <> @CurrentId
AND Field = @CurrentField
AND TermRecord_Id = @CurrentTermId
AND TermsPartRecord_Id = @CurrentTermsPartId

FETCH NEXT FROM TermsCursor INTO @CurrentId, @CurrentField, @CurrentTermId, @CurrentTermsPartId

CLOSE TermsCursor


Disclaimer: I strongly suggest you test this script before running it. It worked fine for us, but use common sense.