[erlang-questions] Accessing two versions of records when doing transform_table in mnesia
Thu Jul 17 11:15:22 CEST 2008
On Thu, 17 Jul 2008, devdoer bird wrote:
db> I can use transform_table to upgrade the table schema in mnesia.
db> Eg.The version 1 of user record's defination is
db> I want to upgrade the user table to version 2
db> I can use transform_table like this:
db> My question is
db> 1. while the upgrade is in in progress, is the user record I read either
db> the version 1 or the version 2 ?That is I can't be sure one user record's
db> current version.
db> 2. while the upgrade is in progress,will the modify of the old user record
db> be lost?
It will differ per module and process. During the upgrade you may have
some processes that are using the old module and some are using the
new module. If this is an issue, you need to perform a more advanced
upgrade procedure that first suspends the processes, then loads the
new code and finaly resumes the processes.
db> 3. If the 1 and 2 are true,how can I code two handle them? Shall I have to
db> have two versions of process code to handle this situation ,like:
db> case of current_version(UserRecord) of
db> v1-> do something;
db> v2->do something
One way of getting better control of this, is to change the name of the record.
Then it will be easy to test which "version" of the record that you are using.
See also mnesia:transform_table/4.
Håkan Mattsson (uabhams)
-------------- next part --------------
erlang-questions mailing list
More information about the erlang-questions