anchor.diff:  ```console
   $ rails generate rails_event_store_active_record:migration --data-type=jsonb
   ```
  -<% end %>
   
   ## Configuring a different mapper
   
  
positive.code:     - `events_class_remapping:` - which can be used for mapping old event names to new ones after you refactored your codebase.
  - [`RubyEventStore::Mappers::Protobuf`](https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store/lib/ruby_event_store/mappers/protobuf.rb)
    - works with Ruby classes generated by `google-protobuf` gem
  
  ### Custom mapper
  
  Mapper needs to implement 3 methods:
  
  - `event_to_serialized_record(domain_event)` - which takes an event and returns `RubyEventStore::SerializedRecord` with given attributes filled out:
    - `event_id` (String)
    - `data` (String)
    - `metadata` (String)
    - `event_type` (String)
  - `serialized_record_to_event(record)` - which takes `RubyEventStore::SerializedRecord` and converts it to an instance of an event class that was stored.
  
  ```ruby
  require 'msgpack'
  
  class MyHashToMessagePackMapper
    def event_to_serialized_record(domain_event)
      # Use data (and metadata if applicable) fields
      # to store serialized representation
      # of your domain event
      SerializedRecord.new(
        event_id:   domain_event.fetch('event_id'),
        metadata:   domain_event.metadata.to_msg_pack,
        data:       domain_event.data.to_msg_pack,
        event_type: domain_event.type
      )
    end
  
    # Deserialize proper object based on
    # event_type and data+metadata fields
    def serialized_record_to_event(record)
      Object.const_get(event_type).new(
        event_id: record.event_id,
        metadata: MessagePack.unpack(record.metadata),
        data:     MessagePack.unpack(record.data)
      )
    end
  
  end
  ```
  
  Check out the code of our [default mapper](https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store/lib/ruby_event_store/mappers/default.rb) and [protobuf mapper](https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store/lib/ruby_event_store/mappers/protobuf.rb) on github for examples on how to implement mappers.
  
  You can pass a different `mapper` as a dependency when [instantiating the client](/docs/install).
  
  
negative.code: # => "bar"
  ```
  
  Another way to achive that could be define your own [custom mapper & transformation](/docs/mapping_serialization/#custom-mapper).
  
  Additionally, if you are using Postgres, you can configure the migration
  to use JSON or JSONB data types for the `data` and `metadata` fields by
  passing in a `--data-type` to the generator
  