Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Breuer 4804 posts 11878 karma points admin mvp c-trib
    Jul 11, 2016 @ 09:45
    Jeroen Breuer
    0

    Manually execute uSync import

    Hello,

    I'm using the Umbraco migrations (https://cultiv.nl/blog/using-umbraco-migrations-to-deploy-changes/) and I would like to make sure that uSync has run before the migration.

    Currently both uSync and the migrations are executed in the ApplicationStarted event. So it's not clear which code will run first.

    In a migration it's possible to also execute code. So in there I could run the uSync import code. Can I just run uSyncBackOffice.ImportAll()?

    Jeroen

  • Kevin Jump 944 posts 5094 karma points mvp c-trib
    Jul 11, 2016 @ 10:18
    Kevin Jump
    100

    hi

    yes, you can just call the back office.

    var uSyncBackOffice = uSyncBackOfficeContext.Instance;
    var actions = uSyncBackOffice.ImportAll()
    

    Then actions will be IEnumberable of uSyncAction if you want to check it all worked or not...

    ImportAll also takes a couple of optional params, so you can even run it from another folder, or force a full import (one where everything is imported even if it hasn't changed) if you want

  • vapenation 21 posts 138 karma points
    Dec 08, 2016 @ 07:51
    vapenation
    0

    I tried this and it seems to have worked but for some reason, Usync didn't create a new log-entry. Does it not do this when you call the API manually?

  • Jeroen Breuer 4804 posts 11878 karma points admin mvp c-trib
    Jul 11, 2016 @ 12:24
    Jeroen Breuer
    0

    Thanks Kevin.

    Do you keep versions when running an import?

    If first would like to run a uSync import, than do my own code migration and than do another import.

    Maybe it's easier to explain what I'm trying to do ;-).

    I have some properties on a child doctype and I need to move it to a parent doctype and keep existing content. So this is my idea:

    1. Rename child doctype properties to temp name (uSync will register)
    2. Create same properties on parent doctype (uSync will register)
    3. Move content from temp child doctype properties to parent properties (migration code).
    4. Delete the temp properties from the child (uSync will register)

    For our CI I need to execute step 1 to 4 in that order. Any suggestions?

    Jeroen

  • Kevin Jump 944 posts 5094 karma points mvp c-trib
    Jul 11, 2016 @ 12:40
    Kevin Jump
    1

    Hi,

    the basic usync code isn't saving versions, but if you have a set of files for each stage, you can just pass the relevant folders into the ImportAll() call, so you might have folders called /step1 /step2 etc...

    you can just call ImportAll("~/mystuff/step1") then Importall("~mystuff/step2") so it would do two or how ever many imports... you wanted to do.

    uSync.Snapshots, will let you make snapshot folders, so you could use that to make a snapshots folder for each stage (they will only contain the changes between each snapshot)

    you could then import these as part of a migration either by calling ImportAll for the right folders or if you use usync. snapshots then you could call something similar to this to apply only one snapshot

    var root = IOHelper.MapPath("~/uSync/Snapshots");
    SnapshotManager snapshotManager = new SnapshotManager(root);
    return snapshotManager.Apply(snapshotName);
    

    Having said all of that, uSync and uSync Content Edition may do what you want in one go.

    If you move your properties to the parent, then umbraco will delete the content when that happens, but if you also import the content files with contentEdition it 'should' put all the content back*

    so a usync import with the doctype changes in it and the content files (produced by content edition) would do both?

    *you might have to do a forced import, because content changes are tracked by save date

  • Jeroen Breuer 4804 posts 11878 karma points admin mvp c-trib
    Jul 11, 2016 @ 12:58
    Jeroen Breuer
    0

    Thanks for your suggestions.

    It's a pretty large project with a lot of content so I prefer to do things manually instead of using uSync Content Edition. I'll try the different folder approach.

    How can I change the folder name? I assume I need to change the folder name. Than do step 1 and 2. Than change the folder name again for step 4?

    Might be easier to manually write the uSync file for deletion since I can't delete it yet.

    Jeroen

  • Kevin Jump 944 posts 5094 karma points mvp c-trib
    Jul 11, 2016 @ 13:02
    Kevin Jump
    1

    yeah from what you're saying i would be inclined to do bits of it by hand.

    Just take the relevant files from the doctype folder and cut/ paste the properties elements. then on sync the properties will be deleted / moved.

    if you used snapshots on the source site, you could just create a new snapshot between each step and then you would have different folders for each change (in the usync/snapshots folder).

Please Sign in or register to post replies

Write your reply to:

Draft