Copied to clipboard

Flag this post as spam?

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


  • dantiago 11 posts 112 karma points
    Nov 07, 2019 @ 13:21
    dantiago
    0

    Re-creating an Umbraco site's database with custom migrations

    Hi all,

    For context, this post follows an issue I raised with Umbraco here: https://github.com/umbraco/Umbraco-CMS/issues/7065#issuecomment-550971305

    I don't think that the response actually addresses my issue but I'm being a good boy, following Sebastiaan's advice and posting it here instead of replying to him.

    I understand that migrations are run once and that their state is stored in the database. However, my question is how that state is added to a new database. The application doesn't run without the presence of the database and configuration within it (i.e. the umbracoLock table) but I can't seem to run the installer in order to create that database!

    I'd be grateful if anyone has any guidance they could offer or thoughts on whether this is actually a bug that I need to go back to Sebastiaan with.

    Thanks,

    Antony

  • dantiago 11 posts 112 karma points
    Nov 11, 2019 @ 15:09
    dantiago
    0

    Bump - anyone had this issue at all? How are other people managing development of Umbraco sites in multi-developer environments?

  • Snow lizard 36 posts 106 karma points
    Nov 11, 2019 @ 15:59
    Snow lizard
    0

    I'd like to know what's best practice here as well!

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Nov 12, 2019 @ 11:19
    David Brendel
    0

    Hi,

    not sure if I get the problem. For multi dev we actually use backups of databases or actually shared ones.

    For the installer, if you remove the connection string and the version from the web.config then the normal installer should be execuded installing all tables in the database. Shouldn't that solve your problem?

    As said not actually sure what your problem is, so maybe I'm way off.

    Regards David

  • dantiago 11 posts 112 karma points
    Nov 12, 2019 @ 11:25
    dantiago
    0

    Thanks for your reply David.

    I'm trying to get away from using backups because, for a complete source control environment, that would require checking a backup into source control and keeping it up to date which is a bit of a pain.

    The approach that you've outlined is exactly what I tried (and what I understood was the correct way to have the installer run again) but that's where I've got an issue.

    The installer is not running and I'm getting runtime errors when trying to run the site instead. I've traced those errors to the Initialize method of one of the custom migrations that have been added.

    It therefore looks to me as if the custom migrations are being run before Umbraco does the check to determine whether it needs to run the installer or not, which is obviously causing an issue because it's trying to run migrations in a non-existent database!

    Hope that clears up the issue.

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Nov 12, 2019 @ 11:26
    Kevin Jump
    100

    Hi,

    How are your custom migrations being initialized?

    are you using a composer/component model to kick off a migration?

    if so, you should check if you are using a composer that implements IUserComposer, as that will not run until Umbraco is installed..

  • dantiago 11 posts 112 karma points
    Nov 12, 2019 @ 11:32
    dantiago
    0

    Ah! This may well be it. All of the composers are inheriting from the ComponentComposer base class.

    I'll update these to inherit from IUserComponent and give that a go. Sounds like the right solution to me though.

    I'll be at the developer meetup you're speaking at tomorrow so I'll be sure to thank you if that solves it!

    Thanks Kevin

  • Snow lizard 36 posts 106 karma points
    Nov 12, 2019 @ 11:33
    Snow lizard
    0

    Thanks for your great Usync package Kevin. I was just watching a video of yours on it

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Nov 12, 2019 @ 11:34
    Kevin Jump
    0

    cool, if it doesn't -

    you can also explicitly set the runtime level (but you shouldn't have too) https://our.umbraco.com/documentation/Implementation/Composing/#runtimelevel

    .. now to go and write that talk for tomorrow ;)

  • dantiago 11 posts 112 karma points
    Nov 12, 2019 @ 22:12
    dantiago
    0

    Thanks Kevin, that did indeed sort it!

Please Sign in or register to post replies

Write your reply to:

Draft