[erlang-questions] Application setup
Sean Hinde
sean.hinde@REDACTED
Sat Jun 16 21:04:37 CEST 2007
create_table will leave the table unchanged (including contents) if
it already exists. In that way it behaves as a handy shorthand for
checking whether the table exists and creating it if it does not.
Sean
On 16 Jun 2007, at 16:00, Kirill Zaborski wrote:
> Seems reasonable but what if I stop application and then restart it
> for some reason? I want to retain all the data that will be
> collected in the application tables (some of them may be persistent).
>
> Regards,
> Kirill
>
> On 6/16/07, Sean Hinde <sean.hinde@REDACTED> wrote:
> On 16 Jun 2007, at 15:08, Kirill Zaborski wrote:
>
> > What is the recommended way to do application setup in OTP? I mean
> > what if my application requires some initialization steps before
> > running? E.g. it requires some mnesia tables created.
> > As I understand for release upgrade I can do this using *.appup
> > files in OTP Design Principles I see only example of process state
> > modification is it OK to transform mnesia tables in code_change/3?
> > And what do I when I install my application first time?
>
> I would suggest to define some record that all parts of your system
> can use to define table definitions, then at system startup doing
> something like:
>
> 1. Find the list of all table definition records.
> 2. Attempt to create all tables.
> 3. Any that are already created (return {aborted,{already_exists,_}})
> compare the fields and if different do a table transform.
>
> This way you not only get the tables created at startup, but you also
> get auto upgrade.
>
> You could do this during startup of one of your first applications.
>
> Sean
>
>
More information about the erlang-questions
mailing list