ralli / bz2redmine

Bugzilla to Redmine migration script
Other
13 stars 8 forks source link

What about PostgreSQL? #2

Open rlogiacco opened 14 years ago

rlogiacco commented 14 years ago

I've PostgreSQL behind both bugzilla and redmine and I wish to use your tool for the migration.

I've changed the require="mysql" to require="pg" and replaced the

return Mysql::new(info.host, info.user, info.password, info.dbname)

with the equivalent for ruby-pg

return PGconn.connect(info.host, 5432, "", "", info.dbname, info.user, info.password)

Now I'm getting errors on the bz_select_sql, red_exec_sql and red_select_sql which, for what I understood, are the three functions used to read/write on the two databases (bugzilla and redmine).

I'm actually trying to convert those functions to their equivalent for the ruby-pg APIs but I'm really noob to ruby so I could appreciate your help.

BTW, I'm trying to migrate form bugzilla 3.2.2 to redmine 0.9.1

ralli commented 14 years ago

Hi, i created a migrate_from_bugzilla rake-task which should also work with PostgreSQL.

You can find it here: http://github.com/ralli/migrate_from_bugzilla

can you please give me feedback, if it worked since i currently have no PostgreSQL installed on my machine (tested with mysql and sqlite).

rlogiacco commented 14 years ago

Here is the output... it fails on something regarding mysql :(

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! no such file to load -- mysql

By the way, I don't have MySQL on my box so the gem install mysql command fails due to lack of headers and libraries.

ralli commented 14 years ago

can you provide more information?

I am a bit surprised, since the migrate_from_bugzilla-script does not contain any mysql-specific code.

HTH

Ralph

ralli commented 14 years ago

Hi, i can reproduce the problem on a box without mysql installed id if i answer the question which adapter i should use with .

Please enter settings for your Bugzilla database adapter [mysql]: host [localhost]: database [bugzilla]: username [bugzilla]: password []: ActiveRecord::BugzillaMigrate::BugzillaBug ActiveRecord::BugzillaMigrate::BugzillaProfile ActiveRecord::BugzillaMigrate::BugzillaProduct ActiveRecord::BugzillaMigrate::BugzillaVersion ActiveRecord::BugzillaMigrate::BugzillaDuplicate ActiveRecord::BugzillaMigrate::BugzillaGroup ActiveRecord::BugzillaMigrate::BugzillaComponent ActiveRecord::BugzillaMigrate::BugzillaDependency ActiveRecord::BugzillaMigrate::BugzillaAttachment ActiveRecord::BugzillaMigrate::BugzillaAttachData ActiveRecord::BugzillaMigrate::BugzillaDescription

Migrating profiles!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! no such file to load -- mysql

(See full trace by running task with --trace)

rlogiacco commented 14 years ago

Well, sorry for late answer but I got busy with other tasks ;-)

I'm now able to run the migration script but it seems to fail on migrating users complaining about a missing user id. I've some users in Bugzilla authenticating against LDAP and for each one of this users I get a failure during migration:

FAILURE #<User id: nil, login: "rlogiacco@smartlab.net", hashed_password: "", firstname: "rlogiacco@smartlab.net", lastname: "rlogiacco@smartlab.net", mail: "rlogiacco@smartlab.net", mail_notification: true, admin: true, status: 1, last_login_on: nil, language: "", auth_source_id: nil, created_on: nil, updated_on: nil, type: "User", identity_url: nil>

What I see strange is the "User id: nil" part which sounds to me like missing id so I went to the Bugzilla database and looked over the profiles table and I can assure you there are ids for each of the failing profiles.... By the way, it seems the same FAILURE statement is not produced for profiles not linked to LDAP accounts....

rlogiacco commented 14 years ago

I've solved the problem caused by non valid firstname and lastname as for LDAP accounts they were set to the email address. I've added the following line to both def lastname and def firstname between the two return statements:

return s.split(/[@]+/).first if(s.include? "@")

I got another error for duplicate key as I had a group defined in redmine which uses the same table for users and groups but groups seems not being deleted from the script. Problem solved manually deleting the group in the redmine database.

Now I'm stuck with a "stack level too deep" error during products migration, here is the pastebin of the stack trace: http://pastebin.com/i8xYriXq

Obviously the last two lines are repeating for a long period and I've stripped them off :-D