Jumoo / uSyncMigrations

Rough and ready migration code.
Mozilla Public License 2.0
48 stars 63 forks source link

Document Type Missing Template Refrence #118

Open JMMM77 opened 1 year ago

JMMM77 commented 1 year ago

When I ran the Migrations I saw that some of the Document Types were missing their Templates. For example, I have a "Standard Content Page" Document Type that is supposed to Allow the "StandardContentPage" Template, but it has not after the migration. But the Template for the Home Page and Contact Us page did keep their document types.

I checked the data folders to see the difference between them but could not spot any obvious differences.

ContactUs.config Template

<?xml version="1.0" encoding="utf-8"?>
<Template>
  <Name>Contact Us</Name>
  <Key>19f4d3b3-5be5-4b52-93a5-7d01d1a49cad</Key>
  <Alias>ContactUs</Alias>
  <Master>Master</Master>
</Template>

StandardContentPage.config Template

<?xml version="1.0" encoding="utf-8"?>
<Template>
  <Name>StandardContentPage</Name>
  <Key>6473fff6-a1ed-4a19-8c71-2a0bfe767de9</Key>
  <Alias>StandardContentPage</Alias>
  <Master>BodyWidgets</Master>
</Template>

Contact Us def.config Document Type

<?xml version="1.0" encoding="utf-8"?>
<DocumentType>
  <Info>
    <Key>d48402d2-a3a8-b04f-cbd4-1ca27e60b179</Key>
    <Name>Contact Us</Name>
    <Alias>ContactUs</Alias>
    <Icon>icon-phone</Icon>
    <Thumbnail>folder.png</Thumbnail>
    <Description></Description>
    <AllowAtRoot>False</AllowAtRoot>
    <IsListView>False</IsListView>
    <Master Key="b4a7382f-7480-e881-d9db-edb3f4904c57">Page</Master>
    <Compositions>
      <Composition Key="1e5fd902-96af-8f71-5444-4a76c5e4cb0b">MasterOverrides</Composition>
      <Composition Key="8b64b514-b0e6-a661-7db5-986309a011e3">PageOverrides</Composition>
      <Composition Key="9ca1e059-f241-d79a-691c-4e6ee3a065cd">RightHandColumn</Composition>
      <Composition Key="b4a7382f-7480-e881-d9db-edb3f4904c57">Page</Composition>
    </Compositions>
    <DefaultTemplate>ContactUs</DefaultTemplate>
    <AllowedTemplates>
      <Template>ContactUs</Template>
    </AllowedTemplates>
  </Info>
  <Structure />
  <GenericProperties />
  <Tabs />
</DocumentType>

Standard Content Page dev.config Document Type

<?xml version="1.0" encoding="utf-8"?>
<DocumentType>
  <Info>
    <Key>334ae0b7-9bb6-aa99-05d6-9170066ffa7b</Key>
    <Name>Standard Content Page</Name>
    <Alias>StandardContentPage</Alias>
    <Icon>icon-document</Icon>
    <Thumbnail>folder.png</Thumbnail>
    <Description></Description>
    <AllowAtRoot>False</AllowAtRoot>
    <IsListView>False</IsListView>
    <Master Key="aee5ce48-d999-f45c-6dc5-5e435d3b5ee4">ContentPage</Master>
    <Compositions>
      <Composition Key="1e5fd902-96af-8f71-5444-4a76c5e4cb0b">MasterOverrides</Composition>
      <Composition Key="4ff66cfd-aa85-bc06-30ea-38e75323947f">MainContent</Composition>
      <Composition Key="8b64b514-b0e6-a661-7db5-986309a011e3">PageOverrides</Composition>
      <Composition Key="9ca1e059-f241-d79a-691c-4e6ee3a065cd">RightHandColumn</Composition>
      <Composition Key="aee5ce48-d999-f45c-6dc5-5e435d3b5ee4">ContentPage</Composition>
      <Composition Key="f3c344d6-0c99-56a5-25d4-2024751b60d4">AdditionalContent</Composition>
    </Compositions>
    <DefaultTemplate>StandardContentPage</DefaultTemplate>
    <AllowedTemplates>
      <Template>StandardContentPage</Template>
    </AllowedTemplates>
  </Info>
  <Structure>
    <DocumentType Key="334ae0b7-9bb6-aa99-05d6-9170066ffa7b">StandardContentPage</DocumentType>
  </Structure>
  <GenericProperties>
    <GenericProperty>
      <Key>2c486b1a-bd17-4878-ae3a-0bf90551a197</Key>
      <Name>Sub Title</Name>
      <Alias>subTitle</Alias>
      <Definition>0cc0eba1-9960-42c9-bf9b-60e150b429ae</Definition>
      <Type>Umbraco.Textbox</Type>
      <Mandatory>false</Mandatory>
      <Validation></Validation>
      <Description><![CDATA[]]></Description>
      <SortOrder>0</SortOrder>
      <Tab>Content</Tab>
    </GenericProperty>
    <GenericProperty>
      <Key>a8c5efff-e395-4031-b3e2-005e6a095540</Key>
      <Name>Tags</Name>
      <Alias>tags</Alias>
      <Definition>8d3f73f5-dd1d-478a-b09c-8341a80d816c</Definition>
      <Type>Umbraco.Tags</Type>
      <Mandatory>false</Mandatory>
      <Validation></Validation>
      <Description><![CDATA[]]></Description>
      <SortOrder>1</SortOrder>
      <Tab>Content</Tab>
    </GenericProperty>
  </GenericProperties>
  <Tabs>
    <Tab>
      <Caption>Main Content</Caption>
      <SortOrder>0</SortOrder>
    </Tab>
    <Tab>
      <Caption>Content</Caption>
      <SortOrder>0</SortOrder>
    </Tab>
  </Tabs>
</DocumentType>

Umbraco 7 image

Umbraco 10 image

KevinJump commented 1 year ago

Hi,

did you have template pages (e.g things in views folder?)

Templates can only be added to doctypes in umbraco when the file exists (its bit of a pain but the way it works).

so if you don't have any views in the views folder (and why would you its a migration). then the template wont get set.

I have been considering adding placeholder .cshtml files pre import as this would at least put the template there - but that probably explains why they are not set post migration.

JMMM77 commented 1 year ago

Hi Kevin,

Thanks for your reply, I doubled checked and confirmed that the views folder did contain the template , please see view folder below, for the StandardContentPage. The strange thing is that the migration is working for some pages but not others. I also noticed that if the tabs in document types had symbols in them that their properties would not be migrated. I got over this by removing the symbols from the tabs in the def.config before running the migration.

Is there a way that I can see the uSync logs to see why it failed to set a template?

image

Please let me know if there are any issues, otherwise great tool :)

Wiggee11 commented 1 year ago

Hi,

did you have template pages (e.g things in views folder?)

Templates can only be added to doctypes in umbraco when the file exists (its bit of a pain but the way it works).

so if you don't have any views in the views folder (and why would you its a migration). then the template wont get set.

I have been considering adding placeholder .cshtml files pre import as this would at least put the template there - but that probably explains why they are not set post migration.

I've been playing with uSync.Migrations yesterday and found this same issue, but no templates have been created (I did not copy/paste the views into the new solution as wasn't aware this was a required step.

@KevinJump If it's simply a case of copying the template files to the Views folder before running the migration, simply adding this step to the documentation would be helpful and I think sufficient. I'm happy to update this but wanted to check this is the intended process first.

Thanks

KevinJump commented 1 year ago

Yes - its a complicated one, because those templates are almost certainly going to require some work as your migrate over to .net core.

But I think creating a template file if there isn't one in already there might make sense- that way you can do either, copy over pre-migration or have blank ones made for you.

the packers (Umbraco 7/8 zip file things) do capture the views folders - so if people have used that (and the migration has a Sites folder) we can could also use that folder as the source (again if the file isn't there before the migration starts).

Wiggee11 commented 1 year ago

I dug into the uSync/migrate/v8 folder and could see it output the Templates folder with expected .config files. I copied my views across, re-ran the migration and it generated the missing templates for my doc types.

I would think that if a doc type has a Template you're always going to want that template reference in the backoffice/associated to the doc type so I would suggest they should always be created. If someone wants to copy the Views across before the migration becuase it helps them migrate the framework code then fine, otherwise create a blank View, because as you say, it's always going to need migrating to .net core.