Copied to clipboard

Flag this post as spam?

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


  • Danny Douglass 28 posts 43 karma points
    Oct 26, 2011 @ 04:43
    Danny Douglass
    0

    Issue Upgrading Umbraco from 4.0.2.1 to 4.7.1 (Database)

    Unfortunately we fell behind with our Umbraco implementation and needed to upgrade several versions at once.  I'm running into an issue where I need to be able to generate Sql scripts to run in production (while maintaining current data).  I am unable to simply use the Umbraco web interface that runs the database upgrades as this can only happen in a development or test environment. 

    The application side took a little bit, but was not that difficult.  Using our current database (v. 4.0.2.1) and new installation of the latest version (v. 4.7.1), I used the redgate sql compare tool to generate a diff script.  While running it I ran into several issues creating various keys and indexes.  Some of these errors were a result of the existing data in our tables.  

    Below I've copied the Sql output of the script execution.  I'm a little stumped at the moment on how to proceed with this upgrade.  Are there incremental scripts available somewhere in the source/core code I could run a version at a time?  I looked through the release on codeplex and did not have much luck finding those artifacts.  Any and all suggestions are greatly appreciated.


    Dropping constraints from [dbo].[cmsContentVersion]
    Creating [dbo].[cmsPreviewXml]
    Creating primary key [PK_cmsContentPreviewXml] on [dbo].[cmsPreviewXml]
    Altering [dbo].[cmsMacro]
    Creating primary key [PK__cmsConte__3213E83F3B75D760] on [dbo].[cmsContentVersion]
    Creating primary key [PK_cmsMember] on [dbo].[cmsMember]
    Creating primary key [PK_cmsStylesheet] on [dbo].[cmsStylesheet]
    Creating primary key [PK_cmsStylesheetProperty] on [dbo].[cmsStylesheetProperty]
    Creating index [IX_Icon] on [dbo].[cmsContentType]
    Creating index [IX_umbracoLog] on [dbo].[umbracoLog]
    Adding constraints to [dbo].[cmsContent]
    Adding constraints to [dbo].[cmsContentType]
    Adding constraints to [dbo].[cmsContentVersion]
    Adding constraints to [dbo].[cmsDataType]
    Adding constraints to [dbo].[cmsDictionary]
    Adding constraints to [dbo].[cmsDocument]
    Adding constraints to [dbo].[cmsTaskType]
    Adding constraints to [dbo].[cmsTemplate]
    Adding constraints to [dbo].[umbracoLanguage]
    Adding constraints to [dbo].[umbracoUser]
    Msg 1505, Level 16, State 1, Line 1
    The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.umbracoUser' and the index name 'IX_umbracoUser'. The duplicate key value is (dxb4).
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsContentTypeAllowedContentType]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContentType' that match the referencing column list in the foreign key 'FK_cmsContentTypeAllowedContentType_cmsContentType1'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsContentVersion]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContent' that match the referencing column list in the foreign key 'FK_cmsContentVersion_cmsContent'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsContentXml]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContent' that match the referencing column list in the foreign key 'FK_cmsContentXml_cmsContent'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsDataType]
    Msg 547, Level 16, State 0, Line 1
    The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_cmsDataType_umbracoNode". The conflict occurred in database "NEB_Test0_Umbraco", table "dbo.umbracoNode", column 'id'.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsDataTypePreValues]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsDataType' that match the referencing column list in the foreign key 'FK_cmsDataTypePreValues_cmsDataType'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsDocument]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContent' that match the referencing column list in the foreign key 'FK_cmsDocument_cmsContent'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsDocumentType]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContentType' that match the referencing column list in the foreign key 'FK_cmsDocumentType_cmsContentType'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsLanguageText]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsDictionary' that match the referencing column list in the foreign key 'FK_cmsLanguageText_cmsDictionary'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsMacroProperty]
    Adding foreign keys to [dbo].[cmsMember]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContent' that match the referencing column list in the foreign key 'FK_cmsMember_cmsContent'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsMember2MemberGroup]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsMember' that match the referencing column list in the foreign key 'FK_cmsMember2MemberGroup_cmsMember'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsMemberType]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContentType' that match the referencing column list in the foreign key 'FK_cmsMemberType_cmsContentType'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsPreviewXml]
    Msg 4902, Level 16, State 1, Line 1
    Cannot find the object "dbo.cmsPreviewXml" because it does not exist or you do not have permissions.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsPropertyData]
    Msg 547, Level 16, State 0, Line 1
    The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_cmsPropertyData_cmsPropertyType". The conflict occurred in database "NEB_Test0_Umbraco", table "dbo.cmsPropertyType", column 'id'.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsPropertyType]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContentType' that match the referencing column list in the foreign key 'FK_cmsPropertyType_cmsContentType'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsStylesheet]
    Adding foreign keys to [dbo].[cmsStylesheetProperty]
    Adding foreign keys to [dbo].[cmsTab]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsContentType' that match the referencing column list in the foreign key 'FK_cmsTab_cmsContentType'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[cmsTask]
    Adding foreign keys to [dbo].[cmsTemplate]
    Msg 1776, Level 16, State 0, Line 1
    There are no primary or candidate keys in the referenced table 'dbo.cmsTemplate' that match the referencing column list in the foreign key 'FK_cmsTemplate_cmsTemplate'.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.
    (1 row(s) affected)
    Adding foreign keys to [dbo].[umbracoDomains]
    Adding foreign keys to [dbo].[umbracoRelation]
    Adding foreign keys to [dbo].[umbracoUser2NodeNotify]
    Adding foreign keys to [dbo].[umbracoUser2NodePermission]
    The database update failed
  • Rich Green 2246 posts 4008 karma points
    Oct 27, 2011 @ 20:55
    Rich Green
    0

    Hi Danny,

    I'm not sure what you mean by this line " I am unable to simply use the Umbraco web interface that runs the database upgrades as this can only happen in a development or test environment. " and I'm not sure what you mean that you got the application side working, how so without the database changes?

    I don't know what your problem is above but upgrading from 4.0.x to 4.7.x isn't going to be that simple.

    I believe the path of least resistance is to upgrade to 4.0.4.2 and then to 4.5.2 and then to 4.7.1 if you use the usual upgrade path using the install routine the scripts should run along the way.

    I don't think the schema has changed much (at all?) since 4.5.x however around this time alot of keys and constraints got added to the db which seems to have something to do with your errors.

    There are a few things to consider along the way, one is that from 4.5.x the XML schema changed, so you will either need to use the legacy schema or rewrite your xslt.  Also packages that worked for 4.0.x may not work for 4.7.

    Don't want to sound too negative, it's totally achievable to upgrade however I doubt there's much documentation on upgrading straight from 4.0.x to 4.7x, however codeplex should document the minor upgrades between versions.

    The versions are all available from here too http://code.leekelleher.com/umbraco/archive/ though this in unofficial.

    Also 4.5.x runs in .NET 4 so watch out for this too.

    Hopefully that helps somewhat.

    Rich


  • Rich Green 2246 posts 4008 karma points
    Oct 28, 2011 @ 10:23
  • Danny Douglass 28 posts 43 karma points
    Oct 28, 2011 @ 22:52
    Danny Douglass
    0

    Thanks a lot Rich.  This is what we are trying to accomplish now - we had hoped it wouldn't be this arduous.  I was aware that the main changes occured in the 4.5.x release in regards to the database. Your responses were very helpful and much appreciated.

    The troubling part here is that the only way to upgrade your database across releases is through the provided "upgrade wizard".  I would REALLY like to have control over the scripts themselves.  Now I'm forced to run a full set of Umbraco upgrades on production in order to get my database up to speed.  As someone who firmly believes in CI process, separation of responsibilities in the deployment pipeline, and Continuous Delivery principles, this is a seriously flawed upgrade strategy.  

    Are there any other resources I'm missing in regards to managing the database upgrades with Umbraco releases that you know?  

  • Rich Green 2246 posts 4008 karma points
    Oct 28, 2011 @ 23:20
    Rich Green
    0

    Hi Danny,

    Glad I could help in someway.

    I'm not sure any upgrades are supposed to be run on production, however simple, I would always pull the site down locally and upload it back up after i've tested it.

    Umbraco, like most software is not perfect, the current code base has been around a *long* time and I doubt CI was on the forefront when it was originally written.

    However with V5 being rewritten from scratch I'm sure things will be much improved.

    I'm not aware of any more documentation.  With regards to having control of the upgrade scripts, I'm sure if you dug around the source code you could fine in the SQL upgrade scripts in their somewhere.

    Best of luck, let us know how you get on.

    Rich 

  • Danny Douglass 28 posts 43 karma points
    Oct 28, 2011 @ 23:53
    Danny Douglass
    0

    Certainly, and I am an adament supporter of Umbraco - it really is a great product.  I fought at my company for quite some time to get it approved.

    When I refer to deploying to production I do not mean the application side of things - that's easy to upgrade in dev/test.  The database however is another issue.  In order to upgrade my production database, I have to run an application upgrade using Umbraco's "upgrade wizard" against that production database unless I do a bunch of manual work using diff tools to compare databases in a before/after upgrade state.  

    I am very much looking forward to v5 and hope improvements have been made on this front, as they have in so many other areas.

    Thanks again Rich.

Please Sign in or register to post replies

Write your reply to:

Draft