Initial Problem:
I want to use :mnesia
in my application.
If I don’t explicitly include :mnesia
in my release, it doesn’t exist.
example:
** (UndefinedFunctionError) function :mnesia.create_schema/1 is undefined
(module :mnesia is not available)
However, if I add it to :extra_applications
so that it gets included in my release, and let it start automatically and create the default schema, I get an error when trying to create tables:
:mnesia.create_table(MyRecord,
disc_copies: [node()],
attributes: [:id, :foo, :bar]
)
with the error:
{:error, {:bad_type, MyRecord, :disc_copies, :nonode@nohost}}
I’m defining the directory in config.exs
config :mnesia, :dir, 'priv/data/mnesia'
And this works fine in dev when I don’t include :mnesia
in my :extra_applications
and I start it manually.
Solution I want to attempt:
I am trying to include :mnesia
in my release, without it starting automatically, so I can start it myself.
I have tried adding it to :included_applications
like so:
def application do
[
mod: {MyApp.Application, []},
extra_applications: [:logger, :runtime_tools],
included_applications: [:mnesia]
]
end
But this gives me an error
** (Mix) Undefined applications: [mnesia]
Anybody have any insight on how I can get this working?
I’ve been trying to get this working for several hours now and really starting to regret choosing mnesia.