Copied to clipboard

Flag this post as spam?

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


  • pnr 131 posts 226 karma points
    Jun 15, 2010 @ 09:42
    pnr
    0

    How do i remove a database table when uninstalling a package

    I have made a package witch create a table in the Umbraco Database, I am creating the table with a usercontrol that execute when my package is installed. My problem is how to remove that table when the package is uninstalled?

    Thanks in advance!

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jun 15, 2010 @ 09:52
    Dirk De Grave
    0

    you should create a package action that's only triggered when uninstalling a package, and that package action should just fire a sql statement to delete the table... you can find more on package actions on the wiki.

    Btw, you could use the same approach when installing the package, just create a package action that fires when installing the package and execute a sql script that creates the table in the database. -> this package action should do fine.

    Cheers,

    /Dirk

  • Richard Soeteman 3875 posts 12037 karma points MVP
    Jun 15, 2010 @ 09:54
    Richard Soeteman
    0

    Hi

    If you use PackageActions and the ExecuteSQL Action from the PackageActionsContrib project you can specify sql to execute during install and uninstall

    Cheers,

    Richard

  • pnr 131 posts 226 karma points
    Jun 15, 2010 @ 12:24
    pnr
    0

    Thanks for your replies!

    I have tried to use the package action, but it isn't creating my table. What can be wrong?

    Tried this:

    <Action runat="install" undo="false" alias="ExecuteSql">  <![CDATA[CREATE TABLE tmp ( [ClientCategoryId] [int] IDENTITY(1,1) NOT NULL)]]></Action>

     

  • Richard Soeteman 3875 posts 12037 karma points MVP
    Jun 15, 2010 @ 12:35
    Richard Soeteman
    0

    Did you include the PackageActionContrib DLL in you package? and I think you need to delete undo="false" Was a bug in previous versions, maybe it still is?

    Cheers,

    Richard

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jun 15, 2010 @ 13:26
    Dirk De Grave
    0

    If you're unsure whether your action is not functioning properly, you may install the package action tester available here, which lets you check if your action is fired.

    And as Richard points out, there used to be/is an issue with the undo attribute.

    Hope this helps.

    /Dirk

  • pnr 131 posts 226 karma points
    Jun 15, 2010 @ 14:54
    pnr
    0

    Sorry i missed that i should include the packageActionContrib.dll, that very much!!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies