[erlang-questions] Where to configure & start mnesia in a release?
Jesper Louis Andersen
Mon Apr 16 11:55:54 CEST 2018
On Sun, Apr 15, 2018 at 1:48 PM Igor Clark <igor.clark@REDACTED> wrote:
> How do I set mnesia application environment variables in the release
> project? (Or, maybe, how do I get the OTP application to be able to
> access the release project's application environment variables?)
> Also, I realise I could be going about this the wrong way - maybe mnesia
> should be configured inside the specific OTP app, even under a release?
One way of going at it, written some time ago when I wrote the GraphQL
A common problem people run into with Mnesia is how to “get started”. What
people often resort to are solutions where an initial database is created
if it doesn’t exist. These solutions are often brittle.
Here, we pick another solution. A helper can create a database schema for
us, with all the necessary tables. The real release *assumes* the presence
of an initial database and won’t boot without one. This means the Erlang
release is simpler. There is always some database from which it can boot
and operate. That database might be the empty database since we are just
starting out. But in particular, the release won’t concern itself with
creating an initial database. Rather it will assume one is already existing.
The situation is not much different than using a traditional
schema-oriented database. Usually, you have to create the database first,
and then populate the schema with some initial data. It is just because of
Rails/Django like systems in which databases are migrate-established, we’ve
started using different models.
Mnesia is part of your release and is started as part of your release, but
its configuration is embedded within the release. This avoids the whole
problem of creation-if-not-exist, which is probably not a good solution for
a database schema, I think. It is convenient... until it accidentally the
whole database you had.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions