Defect #595

Problem migrating from multiple trac projects

Added by Tomoki Tsuchida almost 10 years ago. Updated over 9 years ago.

Status:ClosedStart date:2008-02-03
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Administration
Target version:0.7
Resolution: Affected version:

Description

When multiple trac projects are migrated with rake redmine:migrate_from_trac, any project after the first one fails to be migrated. It also appears that no new issues can be created (issues/add page produces 'internal error.') Upon further investigation, both problems appear to be related with the primary key sequences: after the import, the primary key sequence is not reset, and the next object that is created will try to use a duplicate primary key value.

This occurs in a setup using Postgres. I have not tested with any other databases, so it's possible that this problem is particular to Postgres.

Associated revisions

Revision 1119
Added by Jean-Philippe Lang almost 10 years ago

Use Postgresql's reset_pk_sequence in Trac importer to reset issue id sequence (#595).

History

#1 Updated by Tomoki Tsuchida almost 10 years ago

I have worked around this problem by modifying lib/tasks/migrate_from_trac.rake: I added

def self.reset_pk(klass)
    klass.connection.reset_pk_sequence!(klass.table_name) if klass.connection.respond_to?('reset_pk_sequence!')
end

and for each of the business objects

reset_pk WikiContent
reset_pk Wiki

etc. After this, I could import multiple projects and create new issues without failure.

#2 Updated by Jean-Philippe Lang almost 10 years ago

This problem was fixed in r1099 for postgresql (it doesn't occur with mysql and sqlite).
Note that only the sequence on the 'issues' table need to be updated.

Btw, I'll change my fix to use reset_sequence! instead. Thanks.

#3 Updated by Jean-Philippe Lang almost 10 years ago

  • Status changed from New to Resolved

#4 Updated by Jean-Philippe Lang over 9 years ago

  • Status changed from Resolved to Closed
  • Target version set to 0.7

Also available in: Atom PDF