<div dir="ltr">The whole lets-create-schema-on-first-start-up-if-it-is-not-there is not worth the aggravation IMHO. Personally I would create the schema as a post-condition to installation or pre-condition to starting the application. </div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 10, 2014 at 8:51 PM, Youngkin, Rich <span dir="ltr"><<a href="mailto:richard.youngkin@pearson.com" target="_blank">richard.youngkin@pearson.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Just in case it's helpful to anyone... I've discovered the error of my ways (but I'm still looking towards a solution). This application used to start Mnesia directly after creating the schema (only on the initial startup of course). When creating the release I changed this by adding the mnesia application to the {applications, [...]} tuple in the app.src file. I did this to fix another problem caused by the Mnesia beam files not being included as part of the Erlang distro created by relx.  So in the release version, Mnesia is up and running before the schema is created. So I end up with a started Mnesia application without a schema, which of course is needed to define tables.<div><br></div><div>So now on the my next question, how can I get the schema initialized if Mnesia is started prior to schema creation?  Some guy who gives crappy answers  :) had this post in StackOverflow that gave a partial answer - <a href="http://stackoverflow.com/questions/14083367/mnesia-doesnt-restart-with-supervisor" target="_blank">http://stackoverflow.com/questions/14083367/mnesia-doesnt-restart-with-supervisor</a>.  Is this really the preferred way of doing this? Seems like a bit of a hack to me (but I'm still a newbie, what do I know :>).<br><div><br></div><div>Cheers,</div><div>Rich</div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 8:33 AM, Youngkin, Rich <span dir="ltr"><<a href="mailto:richard.youngkin@pearson.com" target="_blank">richard.youngkin@pearson.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I recently converted an existing application to a release using relx. After that the application isn't able to create any Mnesia tables. I can't reproduce the problem in the Erlang shell (except by creating the table before creating the schema). This is confusing because the app code creates the schema prior to creating the table.</div><div><br></div><div>Here is the error:</div><div><div>12:20:18.929 [info] Creating a new schema from scratch...</div><div>12:20:18.929 [info] Mnesia started, creating tables...</div><div>12:20:18.929 [info] Attempting to create table with TableDef {pe_properties,{disc_copies,[{attributes,[key,value]},{record_name,pe_kvpair}]}}</div><div>12:20:18.931 [error] gen_server pe_membership terminated with reason: bad return value: {error,{unable_to_init_schema,{aborted,{bad_type,pe_properties,disc_copies,'<a href="mailto:prospero@subpubone.ecollege-dev.com" target="_blank">prospero@subpubone.ecollege-dev.com</a>'}}}}</div></div><div><br></div><div><br></div><div>Here's the associated application code:<br></div><div>







<p>      error_logger:info_msg("Creating a new schema from scratch...~n"),</p><p>      %% TODO: TEMP WORKAROUND TO DEBUG MNESIA SCHEMA CREATION PROBLEM</p><p>      application:set_env(mnesia, dir, "/var/data/prospero"),</p><p>      mnesia:create_schema([node()]),</p><p>      mnesia:start(),</p><p>      error_logger:info_msg("Mnesia started, creating tables...", []),</p><p>      case create_tables(pe_migrate:get_schema()) of</p><p><br></p><p>The line application:set_env(...) was added in case the Mnesia directory wasn't getting created properly due to the move to a relx-built release. I had a similar entry in vm.args that I may have gotten wrong (-mnesia dir '"/var/data/prospero"'). Interestingly enough, I don't see any artifacts associated with the schema creation in the Mnesia dir (e.g., schema.DAT). I'm wondering if this is a clue as to what the cause is.</p><p>pe_migrate:get_schema()) returns a list of TableDefs. create_tables iterates through that list creating the tables one at a time. The failure occurs when attempting to create the first table.<br></p><p>Thanks, Rich</p></div></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>