Module: Shared::ProjectUnification

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/shared/project_unification.rb

Overview

Concern for models that need custom conflict handling during project unification

Include this concern in models that have complex validation logic requiring special handling when merging projects.

Examples:

Custom conflict handler

class MyModel < ApplicationRecord
  include Shared::ProjectUnification

  def handle_unify_conflict(target_project_id)
    # Custom logic to resolve conflicts
    self.some_field = "#{some_field}_migrated"
  end
end

Instance Method Summary collapse

Instance Method Details

#handle_unify_conflict(target_project_id) ⇒ nil, ...

Override this method in models that need custom conflict resolution. Called by the migrator when validation fails (uniqueness conflict) after project_id is changed to the target project.

Parameters:

  • target_project_id (Integer)

    The ID of the target project

Returns:

  • (nil, false)

    handler did not persist — migrator will call save!

  • (true)

    handler persisted via update_columns — migrator skips save!, counts as migrated

  • (:destroyed)

    handler destroyed self (merged into existing target record) — counts as destroyed



30
31
# File 'app/models/concerns/shared/project_unification.rb', line 30

def handle_unify_conflict(target_project_id)
end