[erlang-questions] Transform mnesia table into new table
Ryan Brown
ryankbrown@REDACTED
Thu Jun 19 22:37:55 CEST 2014
I have an escript that I can run to update the data in an existing mnesia
table:
#!/usr/bin/env escript
%% -*- erlang -*-
-include("record_defs.hrl").
main([NodeIn|_]) ->
Node = list_to_atom(NodeIn),
ok = migrate_record_schema(Node),
halt().
migrate_record_schema(Node) ->
MigrationFun = fun({
old_record,
Id,
Name,
DateCreated,
DateDeactivated,
Password,
Url
}) ->
{
new_record,
Id,
Name,
DateCreated,
DateDeactivated,
Password,
Url,
false
}
end,
{atomic, ok} = rpc:call(Node, mnesia, transform_table, [old_record,
MigrationFun, record_info(fields, new_record)]),
ok.
The problem I have is that when I deploy the code that uses this new record
schema and update the schema, this new transformed data gets replicated to
the other clustered nodes as well.
So, what I was hoping to do was create a new table say new_record, that I
place the transformed records into. The new code will reference that table.
The yet-to-be-upgraded nodes will still continue to reference the old
schema until they get the new code deployed.
Is this possible without jumping through major hoops? Or, maybe I'm missing
a simpler solution?
Any help would be greatly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140619/e900c6df/attachment.htm>
More information about the erlang-questions
mailing list