Database schema

Hi,

Is there a documentation of the ejabberd's Mnesia database schema anywhere?

I understand that I can grep through the code looking for "-record" and correlate that to entries in the Erlang's table viewer tool, but I hope there's a better way...

Serge

erlang's tv is handy for debugging

I'm not aware of any public documentation. An alternative (or complement) to source code investigation is Erlang's Table Viewer. It is a graphical (Tk) interface to ETS and Mnesia tables.

The easiest way to get TV working with ejabberd is:

  1. You must have ejabberd running on your machine, not on a remote one.
  2. You must have full Erlang/OTP installed, including the graphical part, and the Tk graphical toolkit.
  3. Start ejabberd on interactive mode, that means without -detached, so you get an Erlang console like this:
    Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] [kernel-poll:false]
    
    Eshell V5.5.2  (abort with ^G)
    (eja3@atenea)1>
    ...
    =PROGRESS REPORT==== 12-Jan-2007::13:25:38 ===
             application: ejabberd
              started_at: eja3@atenea
  4. Now start the Table Viewer typing: tv:start().
    tv:start().
    <0.418.0>
    (eja3@atenea)2>

    And a window should appear called 'ETS tables on xx'.

  5. You can view ejabberd's ETS and Mnesia tables interactively, including their content. The GUI looks weird (due to Tk) and sometimes crashes if I maximize a window, but it does not interfere ejabberd normal operations, and is useful for debugging.

Re: database schema

badlop wrote:

I'm not aware of any public documentation. An alternative (or complement) to source code investigation is Erlang's Table Viewer. It is a graphical (Tk) interface to ETS and Mnesia tables.

Yes, I mentioned the Table Viewer in my original posting (which is what I used to examine the tables). However, the table fields are composite, and tv tool can't show the nested elements of a record since records are tuples of arbitrary terms. For example:

-record(passwd, {us, password}).

Here 'us' is actually a composite field containing {Username, Server}. The way to figure it out is really by looking at the record definition in the *.hrl file hoping that it is defined more verbosely...

At least when I write mnesia applications I tend to put all application-specific record definitions in a single file with description of a schema, which makes support much easier.

Oh, well, I'll try to extract the schema data the hard way. Is there a place on the site I can submit that document so that it can be evolved by the community?

Serge

On this forum

asergey wrote:

Yes, I mentioned the Table Viewer in my original posting

Sorry, I didn't read that part. Anyway, I'll re-use the minitutorial sometime on the future :)

asergey wrote:

Oh, well, I'll try to extract the schema data the hard way. Is there a place on the site I can submit that document so that it can be evolved by the community?

You can submit your text to the forums, and people may add comments. Then, you are free to modify your forum post and include those suggestions. Once you consider the text to be almost complete, it could be included on ejabberd Developers Guide.

BTW, the DB schema may vary on future ejabberd versions. So if ejabberd already exports a function that solves the requirement, it's preferable instead of writting Mnesia specific code.

Syndicate content