OTRS Import fails with ForeignKeyViolation

Infos:

  • Used Zammad version: 2.5.0-1531824466.f897e164.xenial
  • Used Zammad installation source: repo
  • Operating system: Ubuntu 16.04
  • Browser + version: Commandline

Expected behavior:

Import from OTRS should complete.

Actual behavior:

Import stops from browser and console with the same error message:

irb(main):010:0> Import::OTRS.start
thread#-: Start import…
thread#-: POST: http://www.changed.url/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Action=>“ZammadMigrator”, :Key=>“changedkey”}
thread#-: loading SysConfig…
thread#-: POST: http://www.changed.url/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>“Export”, :Object=>“SysConfig”, :Limit=>"", :Offset=>"", :Diff=>0, :Action=>“ZammadMigrator”, : Key=>“changedkey”}
Setting.reset_change_id: set new cache, 458183798
Setting.set(‘http_type’, “http”)
Setting.reset_change_id: set new cache, 954344182
Setting.set(‘organization’, “changed name”)
Setting.reset_change_id: set new cache, 299725741
Setting.set(‘system_id’, “86”)
Setting.reset_change_id: set new cache, 691229450
Setting.set(‘ticket_hook’, “OE#”)
thread#-: loading DynamicField…
thread#-: POST: http://www.changed.url/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>“Export”, :Object=>“DynamicField”, :Limit=>"", :Offset=>"", :Diff=>0, :Action=>“ZammadMigrator” , :Key=>“changedkey”}
thread#-: loading State…
thread#-: POST: http://www.changed.url/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>“Export”, :Object=>“State”, :Limit=>"", :Offset=>"", :Diff=>0, :Action=>“ZammadMigrator”, :Key= >“changedkey”}
thread#-: update Ticket::State.find_by(id: 1)
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: http://www.changed.url/otrs/public.pl?Action=ZammadMigrator
thread#-: PARAMS: {:Subaction=>“Export”, :Object=>“Priority”, :Limit=>"", :Offset=>"", :Diff=>0, :Action=>“ZammadMigrator”, :K ey=>“changedkey”}
thread#-: update Ticket::Priority.find_by(id: 1)
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table “ticket_priorities” violates forei gn key constraint “fk_rails_d43af6872e”
DETAIL: Key (updated_by_id)=(3) is not present in table “users”.
: UPDATE “ticket_priorities” SET “updated_by_id” = $1, “updated_at” = $2, “created_at” = $3, “name” = $4 WHERE “ticket_priorit ies”.“id” = $5
from lib/import/otrs/priority.rb:36:in updated?' from lib/import/otrs/priority.rb:28:increate_or_update’
from lib/import/otrs/priority.rb:24:in import' from lib/import/otrs/priority.rb:18:ininitialize’
from lib/import/base_factory.rb:35:in new' from lib/import/base_factory.rb:35:increate_instance’
from lib/import/base_factory.rb:11:in block in import_action' from lib/import/base_factory.rb:39:ineach’
from lib/import/base_factory.rb:39:in import_loop' from lib/import/otrs/priority_factory.rb:10:inimport_loop’
from lib/import/base_factory.rb:9:in import_action' from lib/import/otrs.rb:147:inimport_action’
from lib/import/otrs.rb:73:in import' from lib/import/otrs.rb:162:inupdateable_objects’
from lib/import/otrs.rb:43:in `start’
from (irb):10

Steps to reproduce the behavior:

systemctl stop zammad

zammad run rails c

Setting.set(‘import_otrs_endpoint’, ‘http://changed.url/otrs/public.pl?Action=ZammadMigrator’)
Setting.set(‘import_otrs_endpoint_key’, ‘changedkey’)
Setting.set(‘import_mode’, true)
Import::OTRS.start

We renamed the ticket priorities in OTRS. No additional priorities and all are set to “valid”
I don’t get if it’s a user or a ticket priority issue because it cannot find a key in the table “users”

Thanks!

Hi @Stefan-Schaub - this is a known issue. We haven’t had the time to resolve it yet but there is a workaround available. Please do this for all of your priorities.

Thanks @thorsteneckel :smile:
The import worked flawlessly after opening and saving the prios with root@localhost

1 Like

You’re welcome! Thanks for the feedback.

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