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.
http://piranhacms.org
MIT License
1.99k stars 555 forks source link

Strategy to move blogs, pages etc. #781

Closed rengert closed 5 years ago

rengert commented 5 years ago

I want to launch the next website support by piranha. i do not want to copy & paste but i want tohave a more structured project. i want to move my blocks / pages / site to a new assembly and only the assets should be still in the web project. But i think this could cause issues because the content management system could recognize the move stuff as completely new and i need to setup everything from the scratch.

Is there a better strategy?

tidyui commented 5 years ago

Hi there!

The entities BlockFields, Blocks, PageFields, PostFields and SiteFields and stored with the CLR Type without assembly information. This is because how these types are registered in the global application. This means that it's totally safe to move custom blocks and fields to another project as long as their full type name is the same. You can change their namespace and name when moving them, but then you will need to execute a SQL-script updating the CLRType field on the above mentioned entities in the database.

When it comes to PageTypes, PostTypes and SiteTypes these are stored with full type information, for example:

RazorApp.Models.StandardPage, RazorApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

However, the type name is not a key column and is updated when you import the types. As long as the class names (the id of the content types) remain the same there shouldn't be a problem.

The only exception to the above is when using SelectFields as these are stored with complete assembly information, this is due to how .NET resolves the typename for generic types.

This is something we've logged earlier as an issue when you want to version the project containing the content models. Resolving this from our issue however requires splitting the CLRType field into two fields (TypeName & AssemblyName) which will break backwards compatibility. With this is mind this would have to be done in a major version of Piranha.

Either way, make sure you backup your data before starting to converting the project. Removing the

rengert commented 5 years ago

Thanks for the detailed answer!!! I will give you and update as soon as migration is done.

tidyui commented 5 years ago

Did you solve this? Can I close the issue