Tried to upgrade Nextcloud from v18 to v20 facing problems

I am running a Dockerized instance of nextcloud fromhere:

I updated my docker container instance from Nextcloud v18 to Nextcloud v20 not knowing that i’m not supposed to skip major versions.

Of course that failed. Then I tried Nextcloud v19 instead… Thinking that my data is at v18 so i should be able to upgrade to v19.

But no, I got error:
“Can’t start Nextcloud because the version of the data (20.0.4.0) is higher than the docker image version (19.0.4.2) and downgrading is not supported. Are you sure you have pulled the newest image version?”

It turns out that my pervious attempt at running Nextcloud v20 container, has modified some things, even though it didn’t update the data yet.

I’m looking at version.php file in the hml folder. and it looks like this:

<?php
$OC_Version = array(20,0,4,0);
$OC_VersionString = '20.0.4';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
  'nextcloud' =>
  array (
    '19.0' => true,
    '20.0' => true,
  ),
  'owncloud' =>
  array (
    '10.5' => true,
  ),
);
$OC_Build = '2020-12-15T20:53:34+00:00 7789d1db23b1b2312a83c988a65c4ed8149bbb61';
$vendor = 'nextcloud';

As you can see it looks as though the v20 Nextcloud container from the previous attempt has generated this file…

What should I do to get unstuck? Can someone tell me what manual edits I should make to this file? Perhaps change it to make it look like i’m trying to go from v18 to v19 ? But then I don’t know what the OC_Build value should be. Should I just delete the version.php file and hope that it gets re-generated ??

It is worth mentioning that the version shown in config.php still shows 18 so that leads me to believe the data has not been upgraded to 20 yet.

 'dbtype' => 'mysql',
  'version' => '18.0.0.10',
  'dbname' => 'nextcloud',
  'dbhost' => 'db_nextcloud',

I really need help, my data is being held hostage at this point as I cannot run my old v18 instance, nor can I upgrade to v19 and beyond.

Well… I managed to get out of this pickle myself.

It turns out all I had to do was delete the version.php file, then re-run it with the nextcloud v19 docker container. That allowed me to upgrade from v18 to v19. once that succeeded, I then ran the nextcloud v20 container, which upgraded to v20.

Man, you have saved my day! Thanks a bunch - this trick with deleting the version.php also helped me to recover nextcloud installation.