justSteve
justSteve

Reputation: 5524

Orchard: In what table is the Blog post stored

I'm attempting to export data from an older Orchard db and am having problems finding which table the content of a blog post is stored. I've tried using a number of different 'Search all columns' spocs to search all tables and columns but am not finding text from the post itself.

If I have a blog post where the opening sentence is: This sentence contains a unique word.

I would have expected at least one of the various 'Search all columns' examples to have turned up a table/column. But so far, none have.

thx

Upvotes: 3

Views: 473

Answers (3)

Hong
Hong

Reputation: 18501

Just in case it may be useful for others, the following is the actual SQL query used to migrate an Orchard instance to Umbraco. It is derived from the excellent answers by mdameerand and Iman Salehi:

SELECT t.Title, f.Data, b.Text  FROM dbo.Title_TitlePartRecord t
 inner join dbo.Orchard_Framework_ContentItemRecord f on 
 t.ContentItemRecord_id=f.Id 
  inner join dbo.Common_BodyPartRecord b on 
 b.ContentItemRecord_id=f.Id
  AND  b.Id = (
            SELECT MAX(m2.Id) 
            FROM dbo.Common_BodyPartRecord m2 
            WHERE m2.ContentItemRecord_id = f.Id
        )
  AND  t.Id = (
            SELECT MAX(m2.Id) 
            FROM dbo.Title_TitlePartRecord m2 
            WHERE m2.ContentItemRecord_id = f.Id
        )

Upvotes: 1

Iman Salehi
Iman Salehi

Reputation: 956

Tnx to @mdameer... and the related query of madmeer's answer is this:

 SELECT * FROM dbo.default_Title_TitlePartRecord 
 inner join dbo.default_Orchard_Framework_ContentItemRecord on 
 dbo.default_Title_TitlePartRecord.ContentItemRecord_id=dbo.default_Orchard_Framework_ContentItemRecord.Id 
 inner join dbo.default_Common_BodyPartRecord on 
 dbo.default_Common_BodyPartRecord.ContentItemRecord_id=dbo.default_Orchard_Framework_ContentItemRecord.Id
 where dbo.default_Title_TitlePartRecord.ContentItemRecord_id=90

and this is the rightsolution

Upvotes: 3

mdameer
mdameer

Reputation: 1540

Orchard store data based on two tables, ContentItemRecord and ContentItemVersionRecord, which store meta data for content items like BlogPost, and these content items built from multiple parts, each part has it's table and the relation between the item and it's parts is based on Id (if not draftable) or ContentItemRecord_Id (if draftable) columns

if we take BlogPost type as example, which built from TitlePart, BodyPart, AutoroutePart and CommonPart, and you want to select all the data of post (id = 90), then you can find it's title in TitlePartRecord table (ContentItemRecord_Id = 90), and the body text of it in BodyPartRecord table with same relation as title part record, and the route part in AutorouteRecord table with same relation, and the common meta data in CommonPartRecord (Id = 90).

This is the way to extract data from Orchard database, hope this will help you.

Upvotes: 5

Related Questions