OTRS Migration PostgreSQL ERROR: duplicate key value violates unique constraint

  • Used Zammad version: 6.0.0-1687935419.78a7295d.jammy
  • Used Zammad installation type: package
  • Operating system: Ubuntu 22.04 LTS
  • Browser + version: Firefox
  • Zammad runs on a VM with 4 GB Ram / 2 CPU cores

Expected behavior:

  • Migration from OTRS 6 to Zammad using the command line

Actual behavior:

  • The Migration fails, no matter if it is done via web browser or via command line. On the command line i get the following PostgreSQL Error:
irb(main):001:0> Import::OTRS.start
thread#-: Start import...
thread#-: POST: https://xxx/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Action=>"ZammadMigrator", :Key=>"xxx"}
thread#-: loading SysConfig...
thread#-: POST: https://xxx/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>"Export", :Object=>"SysConfig", :Limit=>"", :Offset=>"", :Diff=>0, :Action=>"ZammadMigrator", :Key=>"xxx"}
Setting.set('http_type', "https")
Setting.set('organization', "xxx GmbH")
Setting.set('system_id', "84")
Setting.set('ticket_hook', "xxx#")
thread#-: loading DynamicField...
thread#-: POST: https://xxx/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>"Export", :Object=>"DynamicField", :Limit=>"", :Offset=>"", :Diff=>0, :Action=>"ZammadMigrator", :Key=>"xxx"}
thread#-: loading State...
thread#-: POST: https://xxx/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>"Export", :Object=>"State", :Limit=>"", :Offset=>"", :Diff=>0, :Action=>"ZammadMigrator", :Key=>"xxx"}
thread#-: update Ticket::State.find_by(id: 1)
thread#-: update Ticket::State.find_by(id: 10)
thread#-: update Ticket::State.find_by(id: 12)
thread#-: update Ticket::State.find_by(id: 13)
thread#-: update Ticket::State.find_by(id: 14)
thread#-: update Ticket::State.find_by(id: 2)
thread#-: update Ticket::State.find_by(id: 3)
thread#-: update Ticket::State.find_by(id: 4)
thread#-: update Ticket::State.find_by(id: 5)
thread#-: update Ticket::State.find_by(id: 6)
thread#-: update Ticket::State.find_by(id: 7)
thread#-: update Ticket::State.find_by(id: 8)
thread#-: update Ticket::State.find_by(id: 9)
thread#-: loading Priority...
thread#-: POST: https://xxx/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>"Export", :Object=>"Priority", :Limit=>"", :Offset=>"", :Diff=>0, :Action=>"ZammadMigrator", :Key=>"xxx"}
thread#-: update Ticket::Priority.find_by(id: 1)
/opt/zammad/vendor/bundle/ruby/3.1.0/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `exec_params': PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_ticket_priorities_on_name" (ActiveRecord::RecordNotUnique)
DETAIL:  Key (lower(name::text))=(2 normal) already exists.
/opt/zammad/vendor/bundle/ruby/3.1.0/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `exec_params': ERROR:  duplicate key value violates unique constraint "index_ticket_priorities_on_name" (PG::UniqueViolation)
DETAIL:  Key (lower(name::text))=(2 normal) already exists.

Steps to reproduce the behavior:

  • Starting the Migration an the Zammad Rails console using following commands:
Setting.set('import_otrs_endpoint', 'https://xxx/otrs/public.pl?Action=ZammadMigrator')
Setting.set('import_otrs_endpoint_key', 'xxx')
Setting.set('import_mode', true)
Import::OTRS.start

I found similar issues but none gave me a fitting solution. Is there any way to continue the migration, ignoring the duplicate database entries?
As the error indicates there is something wrong with the ticket priorities, a took a look on the OTRS. There are the following priorities configured:

Any help is appreciated. Thanks in advance.

Any ideas or suggestions?

Hi @jebel, it must be related to the changes you did to the priorities in OTRS. Mh…

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.