ryanwinchester
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.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
danschultzer
Yeah, I wish documentation and error messages were better in Mnesia.
If Mnesia has already started with
:extra_applications, you should run this instead of:create_schema/1:Otherwise if you only load
:mnesiawith:included_applications, then you should run this:After that,
:mnesia.create_table/2should work. Remember to also run:mnesia.wait_for_tables/2to ensure that the node/cluster is ready.And as I mentioned in the other thread, I believe the error with Mnesia missing from the release is because of a bug in Elixir 1.9.0. 1.9.1 should resolve that.