DB error on upgrade

Discussion forum about Anuko Time Tracker
Post Reply
patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

DB error on upgrade

Post by patricr » Tue Apr 17, 2018 8:11 pm

Time Tracker 1.11 upgrade to 1.17...

After dbinstall.php I get this:

Environment Checks
WEB-INF/templates_c/ directory is writable.
WEB-INF/config.php file exists.
DSN is defined.
PHP version: 5.6.34, good enough.
mysqli PHP extension is loaded.
mbstring PHP extension is loaded.
gd PHP extension is loaded.
Connection to database successful.
There are 20 tables in database.
Error: database schema version query failed. MDB2 Error: no such table

Any idea what is going on? DB is there, it has 20 tables- so what table is it looking for and not finding?

wrc
Posts: 249
Joined: Tue May 25, 2010 8:30 pm

Re: DB error on upgrade

Post by wrc » Tue Apr 17, 2018 8:57 pm

The code that fails at last step:

Code: Select all

  $sql = "select param_value from tt_site_config where param_name = 'version_db'";
  $res = $conn->query($sql);
  if (is_a($res, 'MDB2_Error')) {
    echo('<font color="red">Error: database schema version query failed. '.$res->getMessage().'</font><br>');
  } else {
    $val = $res->fetchRow();
    echo('Database version is: '.$val['param_value'].'.');
  }
If you look at the code, you'll see that tt_site_config table was added around version 1.17.34. I suspect you are upgrading from an earlier version, so the above error message looks normal as the table is indeed missing. After proper upgrade, the error message should no longer appear.

patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

Re: DB error on upgrade

Post by patricr » Tue Apr 17, 2018 9:07 pm

Thank you for a quick reply...
So how I do the upgrade of the DB if the script to do that fails? Can I just add a 21st table called tt_site_config?

wrc
Posts: 249
Joined: Tue May 25, 2010 8:30 pm

Re: DB error on upgrade

Post by wrc » Tue Apr 17, 2018 9:16 pm

Do you see the Updates section below the error and DB Install step?

If so, determine the version of the code that you have (in the footer of your old installation).

Then execute all required steps in sequence from top to bottom.

For example, suppose your existing version is 1.5.80. Then you need to execute all of the following:
- 4 steps in Update database structure (v1.5.79 to v1.6) section.
- Update database structure (v1.6 to v1.14)
- Both steps in Update database structure (v1.14 to v1.17.44)
- Update database structure (v1.17.44 to v1.17.88)

I hope it helps.

patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

Re: DB error on upgrade

Post by patricr » Tue Apr 17, 2018 9:52 pm

Anuko Time Tracker 1.11.44.3634 trying to get to 1.17....

To the next level- I see the steps to upgrade "database structure" on page 2 of the upgrade document. It is not clear to me if database structure is the same as Anuko Time Tracker version number. Above is the information at the bottom of my current Anuko window. 1.11.44.3634.

I never get to the window screen capture shown on that page 2 of the documentation that allows you to select the database upgrade to perform.

Thanks for your suggestions wrc, but something in the document does not seem to be spelled out correctly; I think followed all the steps in the upgrade document correctly.

wrc
Posts: 249
Joined: Tue May 25, 2010 8:30 pm

Re: DB error on upgrade

Post by wrc » Tue Apr 17, 2018 10:08 pm

patricr wrote:
Tue Apr 17, 2018 9:52 pm
I see the steps to upgrade "database structure" on page 2 of the upgrade document.
Could you clarify which upgrade document you are referring to?

If your current version is 1.11.44.3634 - then in dbinstall.php, assuming you see it, you have to execute the 4 steps outlined in the red rectangle in the bottom of the attached picture.
database_upgrade_steps.png
Update steps at the boittom
database_upgrade_steps.png (117.52 KiB) Viewed 702 times

patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

Re: DB error on upgrade

Post by patricr » Tue Apr 17, 2018 10:45 pm

Document link: https://www.anuko.com/time_tracker/inst ... pgrade.htm

I never see the window shown above. Can't do the 4 steps if I never see them. I get the error and no option to update.

I just tried to install, from scratch 1.17, on another server and get this:
===========
Environment Checks
WEB-INF/templates_c/ directory is writable.
WEB-INF/config.php file exists.
DSN is defined.
PHP version: 7.0.28, good enough.
mysqli PHP extension is loaded.
mbstring PHP extension is loaded.
gd PHP extension is loaded.
Connection to database successful.
There are no tables in database. Execute step 1 - Create database structure.
Error: database schema version query failed. MDB2 Error: no such table
===========

I set up my present working version of Time Tracker 2 years ago, and don't remember any of these problems. Linux server, Synology 713+.

I note above, that your screen capture shows 23 tables... mine shows 20. I have a couple custom fields, but the number of tables shows 20 in phpMyAdmin and in then error screen.

In some of my other php web apps installs I remember a step where I upload a db to the sql system, dninstall.php appears to be able to do this- but is not doing it. Mark me confused.

patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

Re: DB error on upgrade

Post by patricr » Tue Apr 17, 2018 11:08 pm

OK- re-reading fresh install directions- uploaded mysql.sql file in the distribution to the empty db. Got the fresh install to work on the other server.

So, why can't the old install with all my old data do the upgrade with dbinstall.php? Will sleep n this and look at it again tomorrow, thanks for help

wrc
Posts: 249
Joined: Tue May 25, 2010 8:30 pm

Re: DB error on upgrade

Post by wrc » Tue Apr 17, 2018 11:14 pm

Are you sure you use the latest version of Time Tracker? If so, which version exactly?

As prior to 1.17.36.4048 there was a bug in dbinstall.php, which was basically causing an exit, because instead of echo there was a die in the code, which was addressed in 1.17.36.4048, but if you use a slightly prior version, then you would not see the tables below.

Code: Select all

  $sql = "select param_value from tt_site_config_ where param_name = 'version_db'";
  $res = $conn->query($sql);
  if (is_a($res, 'MDB2_Error')) {
    echo('<font color="red">Error: database schema version query failed. '.$res->getMessage().'</font><br>');
  }
Above, there was a die instead of echo, in 1.17.36.4047. That would force-exit right away. Compare with old code below.

Code: Select all

  $sql = "select param_value from tt_site_config where param_name = 'version_db'";
  $res = $conn->query($sql);
  if (is_a($res, 'MDB2_Error')) {
    die('<font color="red">Error: database schema version query failed. '.$res->getMessage().'</font><br>');
  } 

patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

Re: DB error on upgrade

Post by patricr » Tue Apr 17, 2018 11:32 pm

Thanks- I will try that tomorrow.

patricr
Posts: 8
Joined: Tue Apr 17, 2018 8:08 pm

Re: DB error on upgrade

Post by patricr » Tue Apr 17, 2018 11:47 pm

WOW- that one bit of code made it all appear to upgrade properly. I thought I had the latest code from last weekend, guess there were changes.

Will see tomorrow if all seems to be well.

Thanks for your persistence!

Post Reply