I am trying to add new column to an existing mnesia table. For that, I use following code.
test()->
Transformer =
fun(X)->
#users{name = X#user.name,
age = X#user.age,
email = X#user.email,
year = 1990}
end,
{atomic, ok} = mnesia:transform_table(user, Transformer,record_info(fields, users),users).
Two records I have
-record(user,{name,age,email}).
-record(users,{name,age,email,year}).
My problem is when I get values from my user table it comes as
{atomic,[{users,sachith,28,sachith@so,1990}]}
Why do I get users record name when I retrieve data from user table?
The table name and the record name are not necessarily the same. You started out with a table called
userholdinguserrecords, and then you transformed all theuserrecords intousersrecords. So when you read from the table, it will returnusersrecords, since that's what the table now contains.