0

我有ChicagoBoss应用程序,我想用来mnesia存储注册用户的数据。

我设置{db_adapter, mnesia}boss.config. 现在我尝试创建 mnesia 数据库和表。

mnesia:stop(),
mnesia:create_schema([node()]),
mnesia:change_table_copy_type(schema, node(), disc_copies),
ok = mnesia:start(),
ExistingTables = mnesia:system_info(tables),
TablesToCreate = (?MODELS ++ ['_ids_']) -- ExistingTables,

lists:foreach(fun(T) ->
                    case T of
                        '_ids_' ->
                            {atomic, ok} = mnesia:create_table('_ids_', [{attributes, [type, id]}, {disc_copies, node()}]);
                        _ ->
                            % get model record
                            ModelRecord = boss_record_lib:dummy_record(lists:nth(1, ?MODELS)),
                            % get model attributes
                            Attributes = ModelRecord:attribute_names(),
                            % setup mnesia tables
                            {atomic, ok} = mnesia:create_table(lists:nth(1, ?MODELS), [{attributes, Attributes}, {disc_copies, Node}])
                    end
                  end,
                  TablesToCreate),

但是我在创建表的两种变体中都崩溃了:

{aborted,{bad_type,my_model, {disc_copies,nonode@nohost}}}

谢谢你。

4

1 回答 1

2

node()on 参数mnesia:create_table应该在一个列表中:

{atomic, ok} = mnesia:create_table('_ids_', [{attributes, [type, id]}, {disc_copies, [node()]}]);
于 2013-06-11T13:22:00.013 回答