|
|
| Author |
Message |
|
| etxuwig at etxb.ericsson. |
Posted: Mon Mar 10, 2003 3:19 pm |
|
|
|
Guest
|
The attached patch to mnesia_schema (mnesia-4.1.3) exports
the do_delete_table/1 function. This is symmetrical to the
already exported do_create_table/1.
The use of both is to be able to do something like the
following:
add_context(Context) ->
mnesia_schema:schema_transaction(
fun() ->
case mnesia:read(context, Context, read) of
[] ->
mnesia:write(#context{id=Context}),
lists:foreach(
fun({TabName, Opts}) ->
Cs = mnesia_schema:list2cs(
add_name(TabName, Opts)),
mnesia_schema:do_create_table(Cs)
end, sub_tables(Context));
_ ->
mnesia:abort({exists, Context})
end).
remove_context(Context) ->
mnesia_schema:schema_transaction(
fun() ->
case mnesia:read(context,Context, write) of
[_] ->
mnesia:delete(context,Context,write),
lists:foreach(
fun({TabName,_}) ->
mnesia_schema:do_delete_table(TabName)
end, sub_tables(Context));
[] ->
mnesia:abort({not_found, Context})
end).
...without totally messing up your database upon partial
failure.
/Uffe
--
Ulf Wiger, Senior Specialist,
/ / / Architecture & Design of Carrier-Class Software
/ / / Strategic Product & System Management
/ / / Ericsson AB, Connectivity and Control Nodes
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| dgud at erix.ericsson.se |
Posted: Mon Mar 10, 2003 3:29 pm |
|
|
|
Guest
|
Ok, will be added in the next patch/release.
/Dan
Ulf Wiger writes:
>
> The attached patch to mnesia_schema (mnesia-4.1.3) exports
> the do_delete_table/1 function. This is symmetrical to the
> already exported do_create_table/1.
>
> The use of both is to be able to do something like the
> following:
>
> 102a103
> > do_delete_table/1,
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|