我有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}}}
谢谢你。