Modify

Opened 3 years ago

Closed 3 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: 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 (1)

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

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by anonymous

Patch to support multiple MySQL databases with Trac

comment:1 Changed 3 years ago by bobbysmith007

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

comment:2 Changed 3 years ago by bobbysmith007

  • Resolution set to fixed
  • Status changed from new to closed

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 Comment

Modify Ticket

Action
as closed The owner will remain bobbysmith007.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.