Copied to clipboard

Flag this post as spam?

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


  • Mads S. Christiansen 6 posts 76 karma points
    May 07, 2019 @ 07:36
    Mads S. Christiansen
    0

    Adding migration to db

    Hi guys,

    I am really struggling getting NPoco working for me. I have been following an example on the forum, and I have got a migration plan, component etc. I have been following the approach by Kevin here:

    https://our.umbraco.com/forum/umbraco-8/95939-create-custom-tables-migration-umbracodatabase-npoco

    But it doesnt create my tables. Is there a full tutotial on this? Either paid or free. I must be missing something.

    I hope to get in the right direction, would be a shame to keep developing on V7 just because of this..

    Br Mads

  • Jamie Pollock 174 posts 853 karma points c-trib
    May 31, 2019 @ 22:46
    Jamie Pollock
    1

    Hi Mads,
    Sorry this is a late reply I've only just started working this myself.

    I recommend looking at this blog post by Stephan Gay from the HQ.

    https://www.zpqrtbnk.net/posts/migrations-in-v8

    Some things have changed since the blog post as it was written a few months before the official release of v8.

    I found it to be very useful. Essentially it's a 3 step process:

    1. Create a Migration which extends the MigrationBase class
    2. Create a IComponent to run the Migration in a MigrationPlan & Upgrader during IComponent .Initialize().
    3. Create a IComposer to add the IComponent to the composition.Components() so it will run.

    Unlike v7 where there was separate umbracoMigrations table now the records of the migration get added to a new table umbracoKeyValue instead.

    Again, I recommend looking at Stephan's blog post it goes into some of the details.

    Some of the key differences are;

    • There isn't an UmbracoUserComponent class, use IComponent instead.
    • For the IComponent class inject the values in the constructor rather than at Initialize().

    I hope this helps or you'll find it helpful in the future

    Jamie

Please Sign in or register to post replies

Write your reply to:

Draft