[erlang-questions] Strategies for updating Mnesia tables

Alexander Lamb <>
Fri May 9 17:07:46 CEST 2008


Hello,

Although Mnesia columns can store any kind of Erlang terms, it can  
happen that we need to add a column after an application is deployed.
I understood (and tried) how to update the table.

However, on the contrary to traditionnal SQL databases, this will have  
an impact on my code. Indeed, something like:

ps_get_profiles(System_Name,Production_Type) ->
	F = fun() -> mnesia:match_object(profiles,{profiles, 
{'_','_','_'},System_Name,Production_Type,'_','_','_'},read) end,
	case mnesia:transaction(F) of
		{atomic, Records}	-> {ok, Records};
		{aborted, Reason}	-> {error, Reason}
	end.

Will simply find 0 records once I add a column, hence failing silently.

Is there a way to match against a variable number of columns, giving  
the first columns patterns. Something like:

	F = fun() -> mnesia:match_object(profiles,{profiles, 
{'_','_','_'},System_Name,Production_Type,'_','_','_', * },read) end,

See the "*" at the end of the match_object match part.

What is the strategy when updating software that necessitates adding  
or changing Mnesia tables.

Thanks,

Alex
--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch






More information about the erlang-questions mailing list