Edgewall Software
Modify

Opened 19 years ago

Closed 4 years ago

#2061 closed enhancement (wontfix)

[patch] bugzilla2trac.py for postgresql

Reported by: munro@… Owned by:
Priority: normal Milestone:
Component: contrib Version: 0.9b1
Severity: minor Keywords: patch bugzilla2trac postgresql
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Hi

To import bugs from Bugzilla into a PostgreSQL database, I needed to make a couple of very minor alterations to the bugzilla2trac.py script (see attached patch which applies to the trunk).

Thomas Munro

Attachments (2)

bugzilla2trac.py.diff (3.6 KB ) - added by munro@… 19 years ago.
bugzilla2trac.py-pgsqlbz.diff (14.0 KB ) - added by admiralnemo@… 14 years ago.
Add support for PostgreSQL-backed Bugzilla as well

Download all attachments as: .zip

Change History (22)

by munro@…, 19 years ago

Attachment: bugzilla2trac.py.diff added

comment:1 by munro@…, 19 years ago

Priority: lownormal

Note that after importing into a new postgres database with bugzilla2trac.py, you also need to update the sequences:

trac⇒ SELECT SETVAL('ticket_id_seq', MAX(id)) FROM ticket; trac⇒ SELECT SETVAL('report_id_seq', MAX(id)) FROM report;

I suppose this could be incorporated into the bugzilla2trac.py script, but it would have to detect that it was talking to postgres as a special case.

comment:2 by asmodai@…, 19 years ago

Aside from one small encode (#2229) all changes from this are in the current version, save the id change.

comment:3 by asmodai@…, 19 years ago

When #2229 gets committed this one can be closed as well.

The current version of the script uses the more portable get_last_id() call, which nowadays (0.9b1+) also supports PostgreSQL.

comment:4 by Christopher Lenz, 19 years ago

Resolution: fixed
Status: newclosed

Fixed in [2356].

comment:5 by Christopher Lenz, 19 years ago

Milestone: 0.9

comment:6 by klaus@…, 18 years ago

Resolution: fixed
Status: closedreopened

The trunk version did not work for me. I had an undefined Error for 'report_id_seq' when calling get_last_id in line 351.

I had to execute """SELECT SETVAL('ticket_id_seq', MAX(id)) FROM ticket; SELECT SETVAL('report_id_seq', MAX(id)) FROM report""" right before calling get_last_id to make the script working.

I can attach the patch file if needed, but the change is rather trivial. I don't know if executing the selects is dirty or not.

Btw my trac version is 0.9.3 but I tried the trunc version of bugzilla2trac.py too.

comment:7 by Christian Boos, 18 years ago

Keywords: postgres added
Milestone: 0.9
Severity: normalminor

comment:8 by sid, 18 years ago

Keywords: review added

path attached, needs to be reviewed

comment:9 by sid, 17 years ago

Keywords: review removed

Removing review keyword. I see that the attached patch has already been incorporated into trunk in [2356]. The only thing remaining is if the change in comment:6 should be incorporated into trunk.

comment:10 by Christian Boos, 17 years ago

Keywords: bugzilla2trac added
Milestone: none

Eventually someone should take care of the maintenance of the bugzilla2trac.py contrib script.

comment:11 by osimons, 16 years ago

Resolution: worksforme
Status: reopenedclosed

Time has passed on this ticket. Some things have already been incorporated as mentioned, but there has also been some 20+ more recent tickets with input and fixes for this script. No good reason to keep this ticket open any longer with a patch from 2005.

Closing as 'seemstoworkforothers'.

in reply to:  11 ; comment:12 by shanec@…, 16 years ago

Resolution: worksforme
Status: closedreopened

Replying to osimons:

Time has passed on this ticket. Some things have already been incorporated as mentioned, but there has also been some 20+ more recent tickets with input and fixes for this script. No good reason to keep this ticket open any longer with a patch from 2005.

Closing as 'seemstoworkforothers'.

I can verify this is still an issue with .11 and the current script. Comment # 6 does provide the solution.

In TracDatabase:init I added:

from trac.db.api import DatabaseManager self.using_postgres = DatabaseManager(self.env).connection_uri.startswith("postgres:")

then just before the call to get_last_id I added:

if self.using_postgres:

c.execute("""SELECT SETVAL('ticket_id_seq', MAX(id)) FROM ticket;

SELECT SETVAL('report_id_seq', MAX(id)) FROM report""")

in reply to:  12 comment:13 by anonymous, 15 years ago

Owner: changed from Jonas Borgström to Jeroen Ruigrok van der Werven
Status: reopenednew

Replying to shanec@…:

I can verify this is still an issue with .11 and the current script. Comment # 6 does provide the solution.

In TracDatabase:init I added:

from trac.db.api import DatabaseManager self.using_postgres = DatabaseManager(self.env).connection_uri.startswith("postgres:")

then just before the call to get_last_id I added:

if self.using_postgres:

c.execute("""SELECT SETVAL('ticket_id_seq', MAX(id)) FROM ticket;

SELECT SETVAL('report_id_seq', MAX(id)) FROM report""")

Thankyou thankyou thankyou for this… It is indeed still a problem and your SELECT SETVAL code finally sorted the problem for me. I also identified some other issues with importing more than one product at a time (see #8566)

comment:14 by Jeroen Ruigrok van der Werven, 14 years ago

Owner: Jeroen Ruigrok van der Werven removed

in reply to:  12 comment:15 by Christian Boos, 14 years ago

Keywords: needinfo added

Replying to shanec@…:

Replying to osimons: …

Closing as 'seemstoworkforothers'.

I can verify this is still an issue with .11 and the current script. comment:6 does provide the solution.

In TracDatabase:init I added: …

Care to provide a patch?

comment:16 by admiralnemo@…, 14 years ago

I don't know if anyone else has any use for it, but I had to patch bugzilla2trac.py to support my Bugzilla, which uses PostgreSQL as its database backend. It uses psycopg2 since it complies with PEP 249 like MySQLdb, so it is essentially a drop-in replacement. I also incorporated the workaround in comment:6, since my Trac environment also uses PostgreSQL.

I also had to make a small change regarding Bugzilla's initialowner and username resolution. I don't know if something changed between Bugzilla releases or not, but I added a new clause to the conditional that checks for Bugzilla versions greater than 3.0. If someone knows more about this, feel free improve.

Finally, I don't *think* this breaks existing MySQL functionality, but I don't have a MySQL database/Bugzilla to test against, so let me know if I overlooked something.

Comments welcome.

by admiralnemo@…, 14 years ago

Add support for PostgreSQL-backed Bugzilla as well

in reply to:  16 comment:17 by Christian Boos, 14 years ago

Component: generalcontrib
Keywords: needinfo removed

Replying to admiralnemo@…:

… Comments welcome.

Looks good, but I think the patch doesn't apply anymore cleanly. Can you please refresh it against current source:trunk/contrib/bugzilla2trac.py?

comment:18 by Ryan J Ollos, 9 years ago

Keywords: postgresql added; postgres removed

comment:19 by figaro, 8 years ago

Keywords: patch added

comment:20 by Ryan J Ollos, 4 years ago

Milestone: not applicable
Resolution: wontfix
Status: newclosed

bugzilla2trac.py is no longer maintainer by Trac developers and is being deleted from the trunk. If you need the plugin, please consider copying it from 1.4-stable and creating a plugin on trac-hacks.org.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.