Ticket #9629 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Creating the necessary tables fails if using MySQL database and installing into second environment

Reported by: anonymous Assigned to: bobbysmith007
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

The trac-admin upgrade fails to create necessary tables in second database of MySQL server if the table already exist in some other database.

The symptoms are lots of 'custom_report table not exist' related errors in log and the fact that the upgrade never get to the "Database is up to date, no upgrade necessary." message even when repeated, not speaking about "The Trac Environment needs to be upgraded. Run "trac-admin upgrade"" messages.

Following patch fixes the problem for MySQL. Note that while the fix look reasonable, you should verify if it works on other databases Trac is supposed to run on.

diff -Naur timingandestimationplugin.original/branches/trac0.12/timingandestimationplugin/dbhelper.py timingandestimationplugin/branches/trac0.12/timingandestimationplugin/db helper.py --- timingandestimationplugin.original/branches/trac0.12/timingandestimationplugin/dbhelper.py 2011-10-13 13:50:24.000000000 +0000 +++ timingandestimationplugin/branches/trac0.12/timingandestimationplugin/dbhelper.py 2011-12-21 13:42:52.000000000 +0000 @@ -86,7 +86,7 @@

if(type(db.cnx) == trac.db.sqlite_backend.SQLiteConnection):

sql = "select count(*) from sqlite_master where type = 'table' and name = %s"

else:

- sql = "SELECT count(*) FROM information_schema.tables WHERE table_name = %s" + sql = "SELECT count(*) FROM information_schema.tables WHERE table_name = %s AND table_schema = schema()"

cnt = get_scalar(env, sql, 0, table) return cnt > 0

Attachments

timingandestimationplugin.patch (0.9 kB) - added by anonymous on 12/21/11 15:00:21.
Patch to support multiple MySQL databases with Trac

Change History

12/21/11 15:00:21 changed by anonymous

  • attachment timingandestimationplugin.patch added.

Patch to support multiple MySQL databases with Trac

12/21/11 20:31:06 changed by bobbysmith007

(In [11059]) fix bugs in db_table_exists re #9629

12/21/11 20:31:52 changed by bobbysmith007

  • status changed from new to closed.
  • resolution set to fixed.

Well the schema() function doesnt exist in postgres, so I can't apply it exactly as is.

Thanks very much for the bug report and patch; sorry this didnt work for you. I had been testing postgresql with many schemas, but only one mysql instance.

Cheers, Russ


Add/Change #9629 (Creating the necessary tables fails if using MySQL database and installing into second environment)




Change Properties
Action