Copied to clipboard

Flag this post as spam?

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


  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Sep 26, 2016 @ 10:52
    Michaël Vanbrabandt
    0

    Upgrade custom database table

    Hi,

    I have a plugin released which has a database table that in a next version will have an extra column.

    In my application event handler if have the following code:

    if (!db.TableExist("customTable"))
        db.CreateTable<CustomTable>(false);
    

    So if the databse doesn't exists, it will create a new one.

    But what with existing tables during a upgrade? What will be the best way to do database changes on existing tables that has already records?

    In my case I need an extra column of type int without null values.

    /Michaël

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Sep 26, 2016 @ 11:02
    Søren Gregersen
    100

    Hi,

    You should use migrations - take a look at this article : https://cultiv.nl/blog/using-umbraco-migrations-to-deploy-changes/

    It will allow you to both up- and down-grade your plugin (downgrade is used for uninstall).

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Sep 26, 2016 @ 11:06
    Michaël Vanbrabandt
    0

    Hi Soren,

    thanks for the link I will have a look at this!

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft