2

I'm trying to update an old site that is still running on Craft 2.2 (from September 2014), but unfortunately the update process to the current version (2.6) breaks.

Does anyone have any experience of upgrading a Craft site from several versions back? I'm thinking my best bet might be to try doing it in a series of steps by downloading intermediate versions from here. I'm wondering though if there are particular version numbers that are good milestones for updating (or best avoided)? (I half remember a version that had to be manually installed a while back) Or alternatively, whether there's a better approach I haven't thought of?

Update: the problematic step seems to be upgrading to 2.5. I've managed to run updates up to the last build of 2.4 but the jump from 2.4 to 2.5 always seems to fail. The error message is just "There was a problem updating your database", so it's hard to know what exactly is going wrong.

  • Did you try manually updating to the latest version? – carlcs Jun 29 '16 at 10:14
  • Yes. I've tried both manually updating and auto-updating. Both times the update ran into the same problem. – Nick F Jun 29 '16 at 10:15
  • 3
    When something goes wrong with an installation, check your Craft.log. Everything gets logged and you should be able to see what's being hung up. I've seen this before with plugins that didn't migrate properly, you may have to disable them first. – RitterKnight Jun 29 '16 at 16:54
  • Ah, thanks. Yep, that's exactly what I did and it helped me finally get to the bottom of the issue (see my answer below for what ended up working) – Nick F Jun 29 '16 at 16:59
4

Ok, after a lot of trial and error I've finally managed to get this site upgraded. Here's a rough outline of the process and what the problem turned out to be:

  • First, I tried updating one minor version at a time. This led me to find that the problem seemed to be with updating from the last build of 2.4 to the first build of 2.5
  • The error message on update wasn't super helpful ("There was a problem updating your database"), but by trawling through Craft's log file (craft/storage/runtime/logs/craft.log) I found that the update seemed to be failing when trying to create the table elementindexsettings because (for whatever reason) that table already existed (resulting in the error Failed to apply migration: m150827_000000_element_index_settings).
  • I can't think why this would be the case, since after each failed update attempt I fully restored my previous database, but since my elementindexsettings table was empty, I dropped it and tried the update again. At this point it worked.

So in summary, the solution was:

  1. Update to Craft 2.4.2726 (and commit this to version control!)
  2. Attempt a manual update to Craft 2.5.2750. When this fails, drop the elementindexsettings table and try running the update again (ie. go to /admin and press the "Finish up" button.
  3. Update to the latest version.

As a side note, I found setting Craft's backupDbOnUpdate config setting to false made the update process much faster and less painful when having to do a lot of attempted updates followed by rollbacks (though obviously if doing this be careful to make sure you have a backup you can restore if the process goes wrong).

| improve this answer | |
  • 1
    If anyone from Pixel & Tonic is reading, I suspect you might be able to make the upgrade process from 2.4 to 2.5 smooth just by adding an "IF NOT EXISTS" clause to the migration in question. – Nick F Jun 29 '16 at 17:46
1

It should just work - but I've had a few instances where the automatic one wouldn't work and had to go manual.

We had one which simply wouldn't work at all - that was a 2.2 to 2.6 upgrade, and it failed when trying to do the database every single time. We rebuilt it from scratch.

More info on exactly how it's breaking for you would help.

| improve this answer | |
  • Ah, that doesn't bode well! We definitely can't rebuild this one from scratch... The particular issue (the immediate issue, at any rate) seems to be that at a certain point the "status" field disappeared from the users table. I've tried recreating it, but then I just run into "an error" (which looks like it might just be a memory limit problem... am looking into that now). Did you try the option of stepped updates at all? (eg. 2.2 --> 2.3, 2.3 --> 2.4, etc) – Nick F Jun 29 '16 at 11:22
  • 1
    Just in case you ever need to do this again, I finally managed to get the upgrade to work... See my answer above for the details. – Nick F Jun 29 '16 at 17:40
  • 1
    Great, thanks! That is indeed the error that had us totally stuck. – Matt Wilcox Jun 30 '16 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.