Opened 9 years ago

Closed 9 years ago

#9629 closed defect (fixed)

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

Reported by: anonymous Owned by: Russ Tyndall
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12


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/ timingandestimationplugin/branches/trac0.12/timingandestimationplugin/db --- timingandestimationplugin.original/branches/trac0.12/timingandestimationplugin/ 2011-10-13 13:50:24.000000000 +0000 +++ timingandestimationplugin/branches/trac0.12/timingandestimationplugin/ 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"


  • 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 (1)

timingandestimationplugin.patch (883 bytes) - added by anonymous 9 years ago.
Patch to support multiple MySQL databases with Trac

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by anonymous

Patch to support multiple MySQL databases with Trac

comment:1 Changed 9 years ago by Russ Tyndall

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

comment:2 Changed 9 years ago by Russ Tyndall

Resolution: fixed
Status: newclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Russ Tyndall.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.