首页 > 代码库 > mnesia 动态改变数据库字段

mnesia 动态改变数据库字段

create() ->
 mnesia:create_table(?ID_TABLE, [{disc_copies, [node()]}, {attributes, record_info(fields, unique_id)}]),
 Fun = fun(Old) ->
    #game_server_data{id=Old#game_server_data_0_0_0.id,
          name=Old#game_server_data_0_0_0.name,
          first_time=Old#game_server_data_0_0_0.first_time,
          pid=Old#game_server_data_0_0_0.pid}
    end,
 mnesia:transform_table(?GAME_SERVER_INFO_TABLE, Fun, record_info(fields, game_server_data)).