[erlang-questions] Accessing two versions of records when doing transform_table in mnesia
devdoer bird
devdoer2@REDACTED
Wed Jul 16 23:44:22 CEST 2008
Hi:
I can use transform_table to upgrade the table schema in mnesia.
Eg.The version 1 of user record's defination is
-record(user_v1,{uuid,name})
I want to upgrade the user table to version 2
-record(user_v2,{uuid,name,email}).
I can use transform_table like this:
transform_table(user,fun({user_v1,Uuid,Name})->#user_v2{uuid=Uuid,name=Name,email=""}
end,record_info(fields,user_v2),user_v2).
My question is
1. while the upgrade is in in progress, is the user record I read either
the version 1 or the version 2 ?That is I can't be sure one user record's
current version.
2. while the upgrade is in progress,will the modify of the old user record
be lost?
3. If the 1 and 2 are true,how can I code two handle them? Shall I have to
have two versions of process code to handle this situation ,like:
process_one_user(UserRecord)->
case of current_version(UserRecord) of
v1-> do something;
v2->do something
end
end
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080717/26109d81/attachment.htm>
More information about the erlang-questions
mailing list