iachat/spec/jobs
Gabriel Jablonski 079d4b4996
fix(conversations): enforce NOT NULL on contact_id + cleanup orphans (#273)
* fix(conversations): enforce NOT NULL + FK on contact_id

Conversations had contact_id nullable with no FK to contacts. Combined
with dependent: :destroy_async on Contact#conversations, deleting a
contact could leave conversations pointing to a missing contact,
breaking the conversations#index API with
"undefined method 'additional_attributes' for nil" from the contact
partial.

Changes:
- Migration cleans up existing orphans, sets contact_id NOT NULL and
  adds a FK with ON DELETE CASCADE so the invariant is enforced at the
  DB level (complements the existing Rails presence validation).
- ContactMergeAction uses update_all for conversations/messages/notes/
  contact_inboxes so a failing callback cannot silently leave records
  pointing to the mergee contact before it is destroyed.
- Drop the now-redundant orphan filter in Conversations::ResolutionJob
  and its spec; the invariant is enforced at the schema level.

* fix: address review feedback

- Drop the ON DELETE CASCADE FK on conversations.contact_id. Several
  conversation-owned tables (messages, mentions, conversation_participants,
  reporting_events, csat_survey_responses, calls, applied_slas, sla_events,
  and polymorphic notifications) still have plain conversation_id references
  without FK cascades. The DB-level cascade would skip Conversation's
  dependent: cleanup and replace the NULL-contact bug with orphan children,
  and would also conflict with the existing non-cascade FKs on
  scheduled_messages/recurring_scheduled_messages. Keep the invariant at the
  Rails layer (NOT NULL + presence validation + dependent: :destroy_async).
- Clean up orphan conversations in the migration via Rails destroy so
  dependent associations are propagated correctly, instead of a raw
  DELETE FROM conversations that would orphan all child rows.
- Revert ContactMergeAction.merge_* methods back to per-record update! so
  Conversation#after_update_commit still fires (notify_status_change /
  CONVERSATION_CONTACT_CHANGED) for contact_id changes. The bang form
  still removes the silent-failure risk of the original .update call.
2026-04-22 13:57:40 -03:00
..
account Merge branch main into chore/merge-upstream-4.7.0 2025-10-16 12:08:20 -03:00
agent_bots fix(agent-bot): stabilize webhook delivery for transient upstream failures (#13521) 2026-03-02 14:18:29 +04:00
agents feat(internal-chat): implement internal chat system for agents (#247) 2026-04-11 13:50:15 -03:00
auto_assignment fix: V2 Assignment service enhancements (#13036) 2026-02-11 12:24:45 +05:30
avatar chore: apply rubocop 2025-09-19 19:44:02 -03:00
campaigns chore: Add validations to campaign model 2025-03-19 17:29:08 -07:00
channels fix: z-api read message (#165) 2025-12-12 09:58:12 -03:00
contacts feat: group conversations (#228) 2026-03-19 21:56:58 -03:00
conversations fix(conversations): enforce NOT NULL on contact_id + cleanup orphans (#273) 2026-04-22 13:57:40 -03:00
crm feat: integrate LeadSquared CRM (#11284) 2025-04-29 09:14:00 +05:30
inboxes fix: remove bulk_auto_assignment_job cron schedule (#13877) 2026-03-31 10:56:59 +05:30
internal Merge branch 'chatwoot/develop' into chore/merge-upstream-4.12.0 2026-03-20 00:27:45 -03:00
labels chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
migration chore: [Snyk] Security upgrade rspec-rails from 6.1.4 to 6.1.5 (#10066) 2024-09-16 09:44:07 +05:30
notification perf: limit the number of notifications per user to 300 (#13234) 2026-01-28 17:35:13 +05:30
scheduled_messages feat: mensagens agendadas (#198) 2026-01-30 22:08:16 -03:00
webhooks Merge branch main into chore/merge-upstream 2025-12-20 12:44:31 -03:00
bulk_actions_job_spec.rb Revert "chore: Upgrade Rails to 7.2.2 and update Gemfile dependencies (#11037)" 2026-02-03 21:09:42 -08:00
conversation_reply_email_job_spec.rb Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
data_import_job_spec.rb fix: stream attachment handling in workers (#12870) 2025-12-05 13:02:53 -08:00
delete_object_job_spec.rb feat: speed up circleci and github actions (#12849) 2025-11-19 15:32:48 +05:30
event_dispatcher_job_spec.rb chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
hook_job_spec.rb feat: integrate LeadSquared CRM (#11284) 2025-04-29 09:14:00 +05:30
mutex_application_job_spec.rb feat: outbound voice call essentials (#12782) 2025-11-24 17:47:00 -08:00
send_on_slack_job_spec.rb fix: issue with slack job (#7179) 2023-05-24 20:22:34 +05:30
send_reply_job_spec.rb fix: Increase the parallelism config to fix flaky tests, revert bad commits (#13410) 2026-01-30 12:49:31 -08:00
slack_unfurl_job_spec.rb feat: Support link unfurling for all the channels within the same connected channel account. (#8033) 2023-10-08 17:55:03 +05:30
trigger_scheduled_items_job_spec.rb Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
webhook_job_spec.rb Merge branch 'chatwoot/develop' into chore/merge-upstream-4.12.0 2026-03-20 00:27:45 -03:00