Class: PactBroker::DB::DataMigrations::SetPacticipantDisplayName

Inherits:
Object
  • Object
show all
Extended by:
Helpers, Pacticipants::GenerateDisplayName
Defined in:
lib/pact_broker/db/data_migrations/set_pacticipant_display_name.rb

Class Method Summary collapse

Methods included from Helpers

column_exists?, columns_exist?

Methods included from Pacticipants::GenerateDisplayName

generate_display_name

Class Method Details

.call(connection) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/pact_broker/db/data_migrations/set_pacticipant_display_name.rb', line 11

def self.call(connection)
  if columns_exist?(connection, :pacticipants, [:name, :display_name])
    connection[:pacticipants].where(display_name: nil).each do | row |
      connection[:pacticipants]
        .where(id: row[:id])
        .update(display_name: generate_display_name(row[:name]))
    end
  end
end