Sha256: fab317f38384fa47f33e232b9349e1d9cd7c333adccee608bbae082ce3fcdad5
Contents?: true
Size: 701 Bytes
Versions: 12
Compression:
Stored size: 701 Bytes
Contents
class ConvertEventPayloads < ActiveRecord::Migration class EventMigration < ActiveRecord::Base self.table_name = :event_capture_events serialize :payload end def up EventMigration.find_each do |event| next unless event.payload.respond_to?(:to_unsafe_h) # Use 'update_column' because with 'update' ActiveRecord will try to # deserialize the existing value first, and will detect that there are # two identical Hashes. Use 'to_unsafe_h' because otherwise all keys # will be deemed unsafe, having not been permitted via the strong # parameters API. event.update_column :payload, event.payload.to_unsafe_h end end def down end end
Version data entries
12 entries across 12 versions & 1 rubygems