PiranhaCMS / piranha.core

Piranha CMS is the friendly editor-focused CMS for .NET that can be used both as an integrated CMS or as a headless API.

Home Page:http://piranhacms.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All rows in Piranha_Pages deleted

MiklosSi opened this issue · comments

While adding a new page type all pages disappeared. However, data from Blocks remained.
I don't even know how it happened, but in what circumstance will all rows from the Piranha_Tables be removed? This shouldn't be possible by any means, except from explicitly being removed.

Could you share your startup code. If you have this line in your startup:

https://github.com/PiranhaCMS/piranha.core/blob/master/examples/RazorWeb/Program.cs#L66

And you remove the old PageTypes from the content type sync, they are considered orphans and will be deleted. Deleting PageTypes will effectively cascade the pages based on those.

Best regards

Yes, I have exactly as it was originally (as in the link above).
However, previously I made several pagetypes, but I added a new that did never show up and I consequently removed that last one. Before I removed that pagetype, I also tried to add it by adding the line with .AddType(typeof(PageTypeModel) without success.

All tables that start with Piranha_Pages*, except Piranha_PageTypes got empty as well as the tables that start with Piranha_Content*.
Piranha_BlockFields and Piranha_Blocks still have the data.

Since there's no code in the framework that deletes pages (unless explicitly calling api.Pages.DeleteAsync(...) besides removing PageTypes, the only explanation is that you at some point during the testing removed all PageTypes except the new one, thus deleting them. Then you reverted your code which inserted the old PageTypes again, but then the pages had already been deleted. I suggest that you remove the call to DeleteOrphans() until you've set up your solution.

Please also share your page type so we can take a look at why it's not importing correctly, this is usually due to some attribute missing on the class itself.

Regards

Ok, now I get it :)
If I remove the call DeleteOrphans() , this cannot happen again?
I don't have that pagetype left as I removed it. It was a very simple type, like a FAQ page. I could use existing blocks, but I wanted something that made difference in the front end.

It was like:

[PageType(Title = "FAQ page")]
public class FaqPageType  : Page<FaqPageType>
{
public class FaqRegion
    {
        [Field(Title = "Question")]
        public StringField Question { get; set; }
        [Field(Title = "Answer")]
        public StringField Answer { get; set; }
    }

    [Region(ListTitle = "List of FAQ")]
    public IList<FaqRegion> Faqs { get; set;}
}

Thank you for your prompt answers!