Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 12, 2023 @ 10:10
    Simon Dingley
    0

    v7 to v8 Migration Results in Empty umbracoMediaVersion Table

    After much work trying to migrate legacy property data from a v7 site to a v8 site, I am very close now to being able to then move from v8 to v10. However, there is one major issue still to resolve. After the v8 migration is completed I am left with no accessible media items. The media tree is populated fine but none of the media can be accessed and that is because there are no records in the umbracoMediaVersion table.

    Here is what I believe to be the related migration

    As far as I can see there are no related errors thrown during the migration yet repeated attempts at the process result in the same outcome.

    If I execute the following query (modified from the migration to be SELECT rather than UPDATE) then I get back what I would expect to be in the table after the migration completes:

    SELECT v.id,m.mediaPath
    FROM cmsMedia m
    JOIN cmsContentVersion v on m.versionId = v.versionId
    JOIN umbracoNode n on v.contentId=n.id
    WHERE n.nodeObjectType='B796F64C-1F99-4FFB-B886-4BF4BC011A9C'
    

    Has anyone else experienced this or could shed some light on why it might be dropping the rows during the migration?

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 13, 2023 @ 08:48
    Simon Dingley
    0

    What appears to be the issue is that there are no content versions in the v8 umbracoContentVersion table that relate to media items.

    If I execute the following query on my v7 database I get results as expected:

    SELECT 
      cv.id, 
      cm.mediaPath 
    FROM 
      [Umbraco_v7].[dbo].cmsMedia AS cm 
      INNER JOIN [Umbraco_v7].[dbo].cmsContentVersion AS cv ON cm.versionId = cv.VersionId 
      INNER JOIN [Umbraco_v7].[dbo].umbracoNode ON cm.nodeId = [Umbraco_v7].[dbo].umbracoNode.id 
    WHERE 
      (
        umbracoNode.nodeObjectType = 'B796F64C-1F99-4FFB-B886-4BF4BC011A9C'
      )
    

    If I then execute the following query on the migrated v8 database I get no results so something is going wrong somewhere else in the migration process.

    SELECT 
      cv.id, 
      cm.mediaPath 
    FROM 
      [Umbraco_v7].[dbo].cmsMedia AS cm 
      INNER JOIN [Umbraco_v7].[dbo].cmsContentVersion AS cv ON cm.versionId = cv.VersionId 
      INNER JOIN [Umbraco_v7].[dbo].umbracoNode ON cm.nodeId = [Umbraco_v7].[dbo].umbracoNode.id 
    WHERE 
      (
        umbracoNode.nodeObjectType = 'B796F64C-1F99-4FFB-B886-4BF4BC011A9C'
      ) 
      AND EXISTS (
        SELECT 
          1 
        FROM 
          [Umbraco_v8].[dbo].[umbracoContentVersion] ucv 
        WHERE 
          ucv.id = cv.id
      );
    
  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 13, 2023 @ 11:38
    Simon Dingley
    0

    Whilst it's not ideal I have managed to put together some scripts to insert the missing content versions and media versions until I can work out what is going wrong in the migration process.

    The following script will select the missing content versions from the v7 database and insert them into the umbracoContentVersions table in the v8 database:

    -- Enable identity insert
    SET IDENTITY_INSERT [Umbraco_v8].[dbo].[umbracoContentVersion] ON;
    
    INSERT INTO [Umbraco_v8].[dbo].[umbracoContentVersion] (
      [id], [nodeId], [VersionDate], [text], 
      [current], [userId], [preventCleanup]
    ) 
    SELECT 
      cv.id, 
      cv.ContentId AS nodeId, 
      cv.VersionDate, 
      un.[text],
      1,
      ISNULL(uu.id, -1), -- if no matching user id then use the admin id of -1
      0 
    FROM 
      [Umbraco_v7].[dbo].cmsMedia AS cm 
      INNER JOIN [Umbraco_v7].[dbo].cmsContentVersion AS cv ON cm.versionId = cv.VersionId 
      INNER JOIN [Umbraco_v7].[dbo].umbracoNode un ON cm.nodeId = un.id
      LEFT JOIN [Umbraco_v8].[dbo].[umbracoUser] uu ON un.nodeUser = uu.id
    WHERE 
      (
        un.nodeObjectType = 'B796F64C-1F99-4FFB-B886-4BF4BC011A9C'
      ) 
      AND NOT EXISTS (
        SELECT 
          1 
        FROM 
          [Umbraco_v8].[dbo].[umbracoContentVersion] ucv 
        WHERE 
          ucv.id = cv.id
      ) 
    
    -- Disable identity insert  
    SET IDENTITY_INSERT [Umbraco_v8].[dbo].[umbracoContentVersion] OFF;
    

    This should then be followed up with the following query to insert the missing media versions into the v8 umbracoMediaVersion table.

    INSERT INTO Umbraco_v8.dbo.umbracoMediaVersion (id, [path])
    SELECT        cv.id, cm.mediaPath
    FROM            Umbraco_v7.dbo.cmsMedia AS cm INNER JOIN
                             Umbraco_v7.dbo.cmsContentVersion AS cv ON cm.versionId = cv.VersionId INNER JOIN
                             umbracoNode ON cm.nodeId = umbracoNode.id
    WHERE        (umbracoNode.nodeObjectType = 'B796F64C-1F99-4FFB-B886-4BF4BC011A9C')
    AND EXISTS (
        SELECT 1
        FROM Umbraco_v8.dbo.umbracoContentVersion ucv
        WHERE cv.id = cv.id
    );
    

    I can now load the media nodes in the v8 back office but still I am missing the images themselves and any property data at this stage which makes me think that also did not make it through the migration.

    Strange that there were no reported errors from Umbraco during the upgrade/migration when in reality it should have failed on something like this and not just dumped the content.

Please Sign in or register to post replies

Write your reply to:

Draft