zammad / zammad

Zammad is a web based open source helpdesk/customer support system
https://zammad.org
GNU Affero General Public License v3.0
4.44k stars 756 forks source link

OTRS migration fails with ForeignKeyViolation #1713

Closed newspeer closed 1 year ago

newspeer commented 6 years ago

Infos:

OTRS Version: 5.0.14 Znuny4OTRS-Repo: 5.0.33 Znuny4OTRS-ZammadMigrator: 1.2.1

Expected behavior:

Migrate from OTRS via command line without errors and interruption

Actual behavior:

Migration aborts with the following error: "ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: FEHLER: Einfügen oder Aktualisieren in Tabelle »ticket_priorities« verletzt Fremdschlüssel-Constraint »fk_rails_d43af6872e« DETAIL: Schlüssel (updated_by_id)=(22) ist nicht in Tabelle »users« vorhanden."

Steps to reproduce the behavior:

Install ruby, mysql/mariadb, nginx, openjdk8, elasticsearch, zammad Follow OTRS migration instructions and "Import via command line".

Yes I'm sure this is a bug and no feature request or a general question.

thorsteneckel commented 6 years ago

Hi @newspeer - It seems that your OTRS is missing a User with the ID 22. Can you please check your OTRS database if there is a record with the ID 22 in the table users?

newspeer commented 6 years ago

Hi @thorsteneckel the user is in the table. I attached a screenshot of the table

b74ac7f6

thorsteneckel commented 6 years ago

Hi @newspeer - please check the following URL on your OTRS with your API Key:

http://*yourotrs.tld*/otrs/public.pl?Action=ZammadMigrator;Key=*APIKEY*;Object=User;Subaction=Export

Is there an entry with the UserID: "22"?

newspeer commented 6 years ago

There is:

otrs

thorsteneckel commented 6 years ago

Hi @newspeer - Thanks for your fast responses. I'll have a look what I can find out with the given information.

thorsteneckel commented 6 years ago

Hi @newspeer - happy new year 🚀 We found the issue causing this. It's a logical / design issue in the current implementation. Priorities get imported before the users, see https://github.com/zammad/zammad/blob/develop/lib/import/otrs.rb#L162 . While trying to import the Priorities the User with the ID 22 is not imported yet and causes the error.

However, we will refactor the import logic from the ground up and fix this issue with this.

As a workaround you can go to your OTRS Priority Admin Interface and update all affected Priorities with the root@localhost user.

Nobsadmin commented 1 year ago

image Any way to EDIT the created by ID? The modified ID is already 1 now but importing still stuck on priorities.