Skip to content

Fix bulk_update_integration_service foreign_key

Issue Link: #344523 (closed)

Summary

Since we are renaming Service to Integration, some data tracker models have inconsistent foreign key names at this time.

Some use service_id and some use integration_id.

When update them together, will get an Exception about association relationship.

Example Project

When users set a integration on a group, and then, they apply the group setting to a project under the group, they'll get a error: service_id not found.

The root cause is that the foreign key name of zentao_data_tracker is integration_id, the foreign key in the other original table ( *data_tracker ) is service_id.

Error log:
ActiveRecord::StatementInvalid - PG::UndefinedColumn: ERROR:  column zentao_tracker_data.service_id does not exist
LINE 1: ...v" = '\x2f55366635464a35755a6738647755300a' WHERE "zentao_tr...
                                                             ^:
  app/services/bulk_update_integration_service.rb:15:in `block in execute'

How to fix

When using the foreign key field, change the hard code to dynamic method.

Merge request reports