Dave Burke : Freelance .NET Web Developer specializing in Online Communities

CS Nuglet: Getting your SQL schema patches in order

I just finished a Community Server 2.0 to 2.1 SP2 upgrade project for a client (one of my clients, not for Telligent) who failed to tell me he had problems upgrading in the past because of database corruption.  I emailed him after unexpectedly hitting upgrade problems and asked, "Is there something about the history of your Community Server 2.0 database that you want to tell me about?" [insert smiley here.]

So I then investigated the database patch situation, the incremental updates each CS upgrade applies in its upgrade script.  These patches are stored in the table cs_SchemaVersion.



As you can see we have a few patches missing.  Fortunately, I think I have every SQL upgrade script ever written stored with each of my archived DBVT SDK projects, so I went back to earlier releases and pulled a few pertinent patches.  I quickly found out that the tables, constraints and so forth in that particular missing patch were already in the database.  Hm.

You see, the problem lies in the fact that the Ugrade.SQL script checks to make sure all patches are applied by checking the contents of the cs_SchemaVersion table and if things are screwy, the current upgrade script won't apply its new patches.

Similar CS 2.0-to-2.1 missing patch incidents have occurred before, with The Johnny-on-the-Spot Wizard providing a SchemaPatch.sql script that you'll find on this CS Forums thread.  I ran it, but still had problems. 

What I ended up doing was filling in the cs_SchemaVersion pieces which did the trick and the upgrade script ran successfully.


Insert into cs_SchemaVersion(Major, Minor, Patch, InstallDate) values (2, 0, 41, GetDate())
Insert into cs_SchemaVersion(Major, Minor, Patch, InstallDate) values (2, 0, 42, GetDate())
Insert into cs_SchemaVersion(Major, Minor, Patch, InstallDate) values (2, 0, 45, GetDate())
Insert into cs_SchemaVersion(Major, Minor, Patch, InstallDate) values (2, 0, 50, GetDate())
Insert into cs_SchemaVersion(Major, Minor, Patch, InstallDate) values (2, 0, 51, GetDate())


Whew, Judy.  That was a bad one!

Comments (2) | Post RSS RSS comment feed

Posted on 2/11/2007 8:02:07 AM by Dave Burke
Categories: Community Server
Tags:

Related posts

Comments (2) -

2/11/2007 8:22:37 PM Permalink

So was this the schema upgrade script that failed to check properly? I would expect any schema modification script to check for pre-requisities, make changes, and rollback if anything failed.

Colin Bowern |

2/11/2007 8:53:44 PM Permalink

Hi, Colin.  Thanks for your question.  I don't know how the corruption occurred.  The patches were applied, but not reflected in the cs_SchemaVersion table.  If you look at the upgrade_from_cs2.x.sql script you'll see it right away.  The logic counts the number of patches in the table and if not a certain number (for CS 2.1 SP2 that number is 57), the patches in that .sql script are not applied, so colums required to create new views, for instance, would be missing.  Hope that answers your question.  Regards!

daveburke |


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke