[erlang-questions] How to upgrade the Mnesia record structure?
Alexander Alexeev
mail@REDACTED
Fri Jun 7 15:12:59 CEST 2013
On Mon, 03 Jun 2013 06:01:27 +0000
yashgt@REDACTED wrote:
> If a record is defined as:
>
> -record(shop, {item, quantity, cost}).
>
> and several records are stored in an Mnesia table, and a few months
> later the structure is changed to : -record(shop, {item, quantity,
> source, company, cost}).
>
> Do we need to migrate ALL existing records in the DB to include the
> additional 2 elements in the tuple? I know that a record is actually
> a tuple. If we leave the existing records untouched, will the
> database get messed becaues of new records coming in with the new
> structure?
>
> Thanks,
> Yash
You can also provide a special "extendable" field (call it a backpack)
of type proplist. In your case initial record would have been:
-record(show, {item, quantity, cost, backpack}).
Then when you would need to store source and company you could write:
#show{
item = Item,
quantity = Quantity,
cost = Cost,
backpack = [{source, Source},{company, Company}]
}
More information about the erlang-questions
mailing list