Skip to content

Instantly share code, notes, and snippets.

@abhijith
Created April 7, 2010 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijith/358678 to your computer and use it in GitHub Desktop.
Save abhijith/358678 to your computer and use it in GitHub Desktop.
is_table_defn_updated() ->
mnesia:table_info(version1, attributes) =/= record_info(fields, version1).
upgrade_version_table() ->
case is_table_defn_updated() of
false -> ok;
true ->
NewAttrs = record_info(fields, version1),
{ atomic, ok } = mnesia:transform_table(version1, (fun transformer/1), NewAttrs)
end.
transformer({ version1, Name, Place }) -> #version1{ name = Name, place = Place };
transformer({ version1, Name, Place, _Animal, _Thing }) -> #version1{ name = Name, place = Place }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment