posts - 380, comments - 634, trackbacks - 117,
Dan Bartels online engineering logbook... Items that I find useful organized for my use, and indexed by google for yours. Here you can find information about Microsoft C# programming, SQL SERVER 2005, Telligent Systems CommunityServer, Dot Net Nuke, Windows Vista / Longhorn, and just about anything else that would compel me to type.

News

What I am Reading:


Professional Community Server

Past books can be viewed on:

Post Categories

Archives

Coding Techniques

Coding Tools

Community Sites

Deal Finders

Friends Businesses

Microsofties

Smartphones

Utilities

my blogmap
My Migration to Community Server Blogs from .Text

My goal was to replicate the blog functionality and site as closely as possible to my original .Text install...  I may use the gallery in the future, but am not so interested in the forum code at the moment.  So here is what I did to get it this far...

I installed the CS source onto my server, and originally mapped the directory to localhost/cs as suggested.  I then made a database named CommunityServer on my SQL server, created a SQLUser with dbo access to this new database, and finally I enabled the Installer script by setting bool INSTALLER_ENABLED = true; ...  Then I ran the installer by browsing to http://localhost/cs/installer and followed the on screen guide.  After my CS site was set up, I proceeded to add a user for myself other than admin.

I followed the guide at http://www.qgyen.net/blog/articles/cs_howto_single_site.aspx to enable my blog and gallery for a single site...  but took it one step further, I moved the standard root into a /cs/ folder and put the blog at the root... So I could use http://blog.danbartels.com (tip, if you do this, you are going to need to change the home.aspx reference in the sitemapping.config to be default.aspx or every sub directory's default.aspx will try to load as home.aspx....  then you should add home.aspx as the primary default document in IIS, so it will override default when present...)

I had to set the page directive at the root web config to:

  < PAGES pageBaseType="CommunityServer.Components.CSFormPage, CommunityServer.Components" / >

and then add the following page directive to the web.config in the /Admin and /cs folder

  < PAGES pageBaseType="CommunityServer.Components.CSPage, CommunityServer.Components" autoEventWireup="true" validateRequest="false"/ >

Now that I had my blog mostly working off the root (I still have a style sheet issue with the login page).  I set out to migrate my data...  Initially I tried the CSVerter tool found at http://weblogs.asp.net/rmclaws/archive/2005/02/25/380496.aspx and also discussed at http://www.communityserver.org/forums/474952/ShowPost.aspx.  I could not get this tool to migrate my blog, but the data seemed simple enough so I just wrote some SQL to make the transfer (note my .Text database name was "BLOG")


Declare @SectionID int
Set @SectionID = 4

Declare @SettingsID int
set @SettingsID = 1000

Declare @UserName varchar(50) --From the aspnet_Users table
set @UserName = 'DanB'

Declare @UserID int
Select @UserID = cs_UserProfile.UserID from aspnet_Users join cs_UserProfile on aspnet_Users.UserID =  cs_UserProfile.MembershipID where UserName = @UserName

Declare @AnonUserName varchar(50)
set @AnonUserName = 'Anonymous'

Declare @AnonUserID int
Select @UserID = cs_UserProfile.UserID from aspnet_Users join cs_UserProfile on aspnet_Users.UserID =  cs_UserProfile.MembershipID where UserName = @AnonUserName



SET IDENTITY_INSERT cs_LinkCategories ON
INSERT INTO [CommunityServer].[dbo].[cs_LinkCategories](LinkCategoryID, [SectionID], [Name], [Description], [IsEnabled], [SortOrder], [SettingsID])
SELECT [CategoryID], @SectionID, [Title], [Description], [Active], 0, @SettingsID FROM [BLOG].[dbo].[blog_LinkCategories] WHERE CategoryType = 0

--Change the URL field in the cs_links to 255 (100 characters might not be enough)

SET IDENTITY_INSERT cs_Links ON
INSERT INTO [CommunityServer].[dbo].[cs_Links]([LinkID], [LinkCategoryID], [Title], [Url], [IsEnabled], [SortOrder], [SettingsID])
SELECT [LinkID], [CategoryID], [Title], [Url], [Active], 0, @SettingsID FROM [BLOG].[dbo].[blog_Links] WHERE Title is not null
GO

SET IDENTITY_INSERT cs_Post_Categories ON
INSERT INTO [CommunityServer].[dbo].[cs_Post_Categories]([CategoryID], [SectionID], [Name], [CategoryType], [IsEnabled], [ParentID], [Description], [SettingsID], [Path])
SELECT [CategoryID], @SectionID, [Title],
CASE [CategoryType]
        WHEN 1
            THEN 2
        ELSE 3
END AS [CategoryType]
, [Active], 0, [Description], @SettingsID, '/' FROM [BLOG].[dbo].[blog_LinkCategories] WHERE CategoryType in (1,2)

SET IDENTITY_INSERT cs_Threads ON
INSERT INTO [CommunityServer].[dbo].[cs_Threads]([ThreadID], [SectionID], [UserID], [PostAuthor], [PostDate], [ThreadDate], [LastViewedDate], [StickyDate], [TotalViews], [TotalReplies], [MostRecentPostAuthorID], [MostRecentPostAuthor], [MostRecentPostID], [IsLocked], [IsSticky], [IsApproved], [RatingSum], [TotalRatings], [ThreadEmoticonID], [ThreadStatus], [SettingsID])
SELECT C.[ID], @SectionID,@UserID ,@UserName, C.[DateAdded], C.[DateAdded], C.[DateAdded], C.[DateAdded], 0 as views, isnull(CountID,0) as FeedbackCount, isnull(FeedbackAuthorID,@UserID ) as LastPosterID, isnull(FeedbackAuthor, @UserName) as LastPosterName, isnull(LatestPost.ID, C.ID) as LastPostID, 0, 0 ,1, 0, 0, 0, 0, @SettingsID
FROM [BLOG].[dbo].[blog_Content] C
LEFT OUTER JOIN (SELECT [ID], CountID, LatestPostIndex.ParentID, Author, DateAdded, @AnonUserID as FeedbackAuthorID, 'Anonymous' as FeedbackAuthor FROM
(SELECT Max([ID]) as MaxID, Count([ID]) as CountID, ParentID FROM [BLOG].[dbo].[blog_Content] where ParentID <> -1 Group by ParentID) LatestPostIndex
join (SELECT [ID], [Title], [DateAdded], [SourceUrl], [PostType], [Author], [Email], [SourceName], [BlogID], [Description], [DateUpdated], [TitleUrl], [Text], [ParentID], [FeedBackCount], [PostConfig], [EntryName] FROM [BLOG].[dbo].[blog_Content]) Posts
on LatestPostIndex.MaxID = Posts.ID) LatestPost
ON C.ID = LatestPost.ParentID
Where PostType in (1,2)
GO

SET IDENTITY_INSERT cs_Posts ON
INSERT INTO [CommunityServer].[dbo].[cs_Posts]([PostID], [ThreadID], [ParentID], [PostAuthor], [UserID], [SectionID], [PostLevel], [SortOrder], [Subject], [PostDate], [IsApproved], [IsLocked], [IsIndexed], [TotalViews], [Body], [FormattedBody], [IPAddress], [PostType], [EmoticonID], [PropertyNames], [PropertyValues], [SettingsID], [AggViews])
SELECT [ID],
CASE [ParentID]
        WHEN -1
            THEN [ID]
        ELSE [ParentID] 
END AS [ThreadID],
CASE [ParentID]
        WHEN -1
            THEN [ID]
        ELSE [ParentID] 
END AS [ParentID],
CASE [ParentID]
        WHEN -1
            THEN @UserName
        ELSE @AnonUserName
END AS [Author],
CASE [ParentID]
        WHEN -1
            THEN @UserID
        ELSE @AnonUserID
END AS [UserID], 
@SectionID,
CASE [ParentID]
        WHEN -1
            THEN 1
        ELSE 2
END AS [Level], 
0 as SortOrder,
[Title], [DateAdded], 1, 0, 0, isnull(WebCount,0), [Text],[Text], isnull([SourceName],'127.0.0.1') as IP, 1,0,

--Note the 4 below might be related to the site ID, I am not sure where the other numbers
--are coming from, you should do a sample post and make a followup to be sure the numbers match
CASE [ParentID] 
        WHEN -1
            THEN 'EnableRatings:S:0:4:EnableTrackBacks:S:4:4:EverPublished:S:8:4:'
        ELSE 'SubmittedUserName:S:0:11:EverPublished:S:11:4:'
END AS [PropertyNames], 
CASE [ParentID]
        WHEN -1
            THEN 'TrueTrueTrue'
        ELSE [Author] + 'True'
END AS [PropertyValues], 
@SettingsID,
isnull(AggCount,0) FROM [BLOG].[dbo].[blog_Content] LEFT OUTER JOIN [BLOG].[dbo].[blog_EntryViewCount] on [BLOG].[dbo].[blog_Content].[ID] = [BLOG].[dbo].[blog_EntryViewCount].[EntryID]
GO


INSERT INTO [CommunityServer].[dbo].[cs_weblog_Posts]([PostID], [PostName], [Excerpt], [TitleUrl], [PostConfig], [BlogPostType], [SettingsID], [BloggerTime])
SELECT [ID], [EntryName], [Description], [TitleUrl],
CASE [ParentID]
        WHEN -1
            THEN 9
        ELSE 0 
END AS [PostConfig],
CASE [ParentID]
        WHEN -1
            THEN 1
        ELSE 4 
END AS [BlogPostType],
@SettingsID,[DateAdded] FROM [BLOG].[dbo].[blog_Content]
GO

INSERT INTO [CommunityServer].[dbo].[cs_Posts_InCategories]([CategoryID], [PostID], [SettingsID])
SELECT [CategoryID], [PostID], @SettingsID FROM [BLOG].[dbo].[blog_Links] where PostID <> -1
GO

UPDATE [CommunityServer].[dbo].[cs_weblog_Posts] SET BlogPostType = 2 FROM [CommunityServer].[dbo].[cs_weblog_Posts] wp JOIN [CommunityServer].[dbo].[cs_Posts_InCategories] pic ON wp.PostID = pic.PostID JOIN [CommunityServer].[dbo].[cs_Post_Categories] pc ON pic.CategoryID = pc.CategoryID WHERE CategoryType = 3 AND BlogPostType <> 4
GO

This does not currently port the galleries, skins, post images, or the number of trackbacks..  the latter can easily be transferred from the blog_Config table into the new dbo.cs_weblog_Weblogs table...

Dan

Tomorrow I will tackle my images and skin, and perhaps even try the galleries.

Published Monday, March 07, 2005 7:35 AM by admin

Filed under
::

Comments

# Steps to migrate my blog from .Text to CommunityServer v1 @ Thursday, March 17, 2005 3:57 AM

Install CommunityServer v1 on my server account. This step is completed with the help of the Installer...

Smartwombat Blog

# My Migration to CS::Blogs @ Thursday, March 17, 2005 12:47 PM

So, mainly because of my comment problems with dottext 0.95, I decided to go
ahead and take the plunge....

Blue Phoenix

# My Migration to CS::Blogs @ Thursday, March 17, 2005 12:48 PM

.NET Blog - Chris Frazier Style

# re: My Migration to Community Server Blogs from .Text @ Sunday, March 27, 2005 1:28 PM

I found two tiny errors in this script:

, [Active], 0, [Description], @SettingsID '/' FROM [BLOG].[dbo].[blog_LinkCategories] WHERE CategoryType in (1,2)

is missing a comma: @SettingsID , '/'
and

JOIN [CommunityServer].[dbo].[cs_Post_Categories} pc ON

} should be replaced with ].

gyurisc

# Pushing my old stuff to Community Server! @ Monday, March 28, 2005 4:31 AM

Finished migrating the data stuff...

Smartwombat Blog

# re: My Migration to Community Server Blogs from .Text @ Thursday, March 31, 2005 3:42 PM

Thanks, I updated the above script with the corrections.

Dan

admin

# re: My Migration to Community Server Blogs from .Text @ Monday, April 04, 2005 4:47 AM

Please feel free to tell me to bugger off.

You appear to be relatively adept at SQL. More so than me, at any rate.
I am trying to migrate from .Text to another .Text, and I figured I might be able to use your SQL to get closer to what I need to do.

Everything was going pretty well, until I tried to migrate the actual posts/comments.

I was wondering if you could/would help me try to get it worked out.

THANKS!

vern

# re: My Migration to Community Server Blogs from .Text @ Monday, April 04, 2005 4:47 AM

Oh yeah;
v g blog AT the gill family DOT us


THANKS!

vern

# re: My Migration to Community Server Blogs from .Text @ Tuesday, April 05, 2005 1:51 PM

The magic with the scripts is in the fact that the Community Server build starts its auto number keys at 1000, so as long as you have less than 1000 comments and posts, you can insert the data into the community server database by just using your old identity keys. By using these keys there is much less need for intelligence in the script.

I would imagine that in moving or merging .Text databases that you will have key collisions or places where the same auto number key is already being used to represent another value.

One option to get around this, would be to use something like adding say 10000 to all of the integer keys in one of the databases... Then you should not have any collisions

Good luck...
Dan

DanB

# Comments closed @ Monday, May 23, 2005 3:09 PM

Rob Eberhardt

# Comments closed? @ Monday, May 23, 2005 3:20 PM

Rob Eberhardt

Leave a Comment

(required) 
(required) 
(optional)
(required) 
 
Powered by Community Server (Commercial Edition), by Telligent Systems
powered by god (with a little help from Telligent Systems - Community Server 2.1)