I love the smell of a fresh #umbraco installation. V5 may be awesome, but you can't argue with 4.7.1.1 with #uComponents either.

follow me on

Upgrading Umbraco v4 to the latest version

Wednesday, September 10, 2008 by David Conlisk

So here's the situation. I have an existing site in development in Umbraco v3 that I want to upgrade to v4. I have a version of v4 from Codegarden so I create a new website with these files, update the web.config and point it to a new copy of my existing v3 database for my site. I also update the umbracoConfigurationStatus setting in the web.config to an empty string. I open up a browser and hit the site, and hey presto the install wizard kicks in. It recognises the v3 database and updates it and we're good to go. No errors or nothing!

The first thing I checked was to see if the templates had been created properly as .NET master templates on the file system - the folder was empty. However, after logging into the Umbraco admin section and going to the templates area of the Settings section the files were created on the file system. Phew!

The next step was to copy across all of the non-standard stuff from my existing Umbraco v3 site to the new v4 site. This includes xslt, css, and scripts. It also includes any user controls that I had created, or that were created by packages that I'd installed, plus any dlls required for these. Also any other dlls that you may use, for example I use the Microsoft Enterprise Libraries for my .NET user controls and so I had to copy them across to the bin directory of my v4 site. Don't forget to update the web.config with any of your own changes, such as appSettings and any configuration settings for Enterprise libraries, etc. And that should be that.

So far so good then. Now to upgrade to the latest nightly build from http://nightly.umbraco.org/umbraco%204.0/. I copy the new files over the top of my v4 site and see how it goes. I can browse the site fine, so it's looking good. But when I log into the back-end, I get this error with the content tree. Pretty confusing, but luckily help was at hand from those friendly folk at Connect Digital, Adam and Paul.

The solution is this. To fix the content tree, run the following piece of SQL code against your v4 database to upgrade it:

/* Add ActionBrowse as a default permission to all user types that have ActionUpdate */
UPDATE umbracoUserType SET userTypeDefaultPermissions = userTypeDefaultPermissions + 'F' WHERE CHARINDEX('A',userTypeDefaultPermissions,0) >= 1 AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1;
/* Add ActionToPublish to all users types that have the alias 'writer'
*/
UPDATE umbracoUserType SET userTypeDefaultPermissions =
userTypeDefaultPermissions + 'H' WHERE userTypeAlias = 'writer'
AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1
;
/* Add ActionBrowse to all user permissions for nodes that have the
ActionUpdate permission */
IF NOT EXISTS (SELECT permission FROM umbracoUser2NodePermission WHERE
permission='F')
INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission)
SELECT userID, nodeId, 'F' FROM umbracoUser2NodePermission WHERE
permission='A'
;
/* Add ActionToPublish permissions to all nodes for users that are of
type 'writer' */
IF NOT EXISTS (SELECT permission FROM umbracoUser2NodePermission WHERE
permission='H')
INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission)
SELECT DISTINCT userID, nodeId, 'H' FROM umbracoUser2NodePermission
WHERE userId IN
(SELECT umbracoUser.id FROM umbracoUserType INNER JOIN umbracoUser ON
umbracoUserType.id = umbracoUser.userType WHERE
(umbracoUserType.userTypeAlias = 'writer'))
;
/* Add the contentRecycleBin tree type */
IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE
treeAlias='contentRecycleBin')
INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder,
appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen,
treeHandlerAssembly, treeHandlerType)
VALUES (0, 0, 0, 'content', 'contentRecycleBin', 'RecycleBin',
'folder.gif', 'folder_o.gif', 'umbraco',
'cms.presentation.Trees.ContentRecycleBin')
;
/* Add the UserType tree type */
IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE
treeAlias='userTypes')
INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder,
appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen,
treeHandlerAssembly, treeHandlerType)
VALUES (0, 1, 1, 'users', 'userTypes', 'User Types', 'folder.gif',
'folder_o.gif', 'umbraco', 'cms.presentation.Trees.UserTypes')
;
/* Add the User Permission tree type */
IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE
treeAlias='userPermissions')
INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder,
appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen,
treeHandlerAssembly, treeHandlerType)
VALUES (0, 1, 2, 'users', 'userPermissions', 'User Permissions',
'folder.gif', 'folder_o.gif', 'umbraco',
'cms.presentation.Trees.UserPermissions')
;

UPDATE: In general when updating to the latest version you need to check this total.sql script to see what db changes have been made since the last build. You can find it on codeplex in the /datalayer/sqlhelpers folder: http://www.codeplex.com/umbraco/SourceControl/FileView.aspx?itemId=448991&changeSetId=39999 The latest changes can be found at the end of the script.

And Paul also gave me these details for another change required for the Media section:

There's also another change that needs to be made: you need to update the "Media" line in dbo.umbracoAppTree otherwise you won't be able to create media items. The values should be:

AppAlias = "media"
TreeAlias = "media"
TreeTitle = "Media"

So there you have it. A bit of a messy upgrade, yes, but remember: we are playing with pre-production beta releases here and we only have ourselves to blame! However, by going through these kinds of things we get access to the latest and greatest Umbraco features - hello master documenttypes!

 

If you found this article useful, please click the +1 button!

 

2 comment(s) for “Upgrading Umbraco v4 to the latest version”

  1. Gravatar of PeterD


    PeterD says:

    Thanks, really helped me to fix some troubles I had when upgrading my testsite to the latest build!
  1. Gravatar of Doug Rathbone


    Doug Rathbone says:

    You have saved me from the end of a 3 day battle with my upgrade... the sql above is a god send

    thank you, thank you, thank you

    Doug

Please leave a comment: