title: Best strategy for "mutable" records in Erlang
body: <p>I develop the system where I assume will be many users. Each user has a profile represented inside the application as a record. To store user's profile I do the following <code>base64:encode_to_string(term_to_binary(Profile))</code>, so basically profiles stored in serialized maner.</p>
  
  <p>So far everything is just fine. Now comes the question:</p>
  
  <p>From time to time I do plan to extend profile functionality by adding and removing certain fields in it. My question is what is a best strategy to handle these changes in the code?</p>
  
  <p>The approach I see at the moment is to do something like this:</p>
  
  <pre><code>Profile = get_profile(UserName),
  case is_record(Profile, #profile1) of
      true -&gt;
          % do stuff with Profile#profile1
          ok;
      _ -&gt;
          next
  end,
  case is_record(Profile, #profile2) of
      true -&gt;
          % do stuff with Profile#profile2
          ok;
      _ -&gt;
          next
  end,
  </code></pre>
  
  <p>I want to know if there are any better solutions for my task?</p>
  
  <p><b>Additional info:</b> I use is simple KV storage. It cannot store Erlang types this is why I use <code>State#state.player#player.chips#chips.br</code></p>