From 261b7dc0d94d6de84a3a0a8b6694eb88730273d6 Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 16 Jun 2009 17:46:08 +0000 Subject: [PATCH] Migration code for people using previous version of the HTTP binding module (EJAB-390) SVN Revision: 2230 --- src/web/ejabberd_http_bind.erl | 24 +++++++++++++++++++----- src/web/mod_http_bind.erl | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/web/ejabberd_http_bind.erl b/src/web/ejabberd_http_bind.erl index e68ef8a8e..b0204c1cc 100644 --- a/src/web/ejabberd_http_bind.erl +++ b/src/web/ejabberd_http_bind.erl @@ -4,12 +4,12 @@ %%% Purpose : Implements XMPP over BOSH (XEP-0205) (formerly known as %%% HTTP Binding) %%% Created : 21 Sep 2005 by Stefan Strigler -%%% Id : $Id: ejabberd_http_bind.erl 408 2007-11-08 15:48:24Z badlop $ +%%% Id : $Id: ejabberd_http_bind.erl 430 2007-11-27 22:03:44Z badlop $ %%%---------------------------------------------------------------------- -module(ejabberd_http_bind). -author('steve@zeank.in-berlin.de'). --vsn('$Rev: 408 $'). +-vsn('$Rev: 430 $ '). -behaviour(gen_fsm). @@ -88,9 +88,7 @@ %%% API %%%---------------------------------------------------------------------- start(Sid, Key) -> - mnesia:create_table(http_bind, - [{ram_copies, [node()]}, - {attributes, record_info(fields, http_bind)}]), + setup_database(), supervisor:start_child(ejabberd_http_bind_sup, [Sid, Key]). start_link(Sid, Key) -> @@ -923,3 +921,19 @@ check_default_xmlns({xmlelement, Name, Attrs, Els} = El) -> true -> El end. + +setup_database() -> + migrate_database(), + mnesia:create_table(http_bind, + [{ram_copies, [node()]}, + {attributes, record_info(fields, http_bind)}]). + +migrate_database() -> + case mnesia:table_info(http_bind, attributes) of + [id, pid, to, hold, wait, version] -> + ok; + _ -> + %% Since the stored information is not important, instead + %% of actually migrating data, let's just destroy the table + mnesia:delete_table(http_bind) + end. diff --git a/src/web/mod_http_bind.erl b/src/web/mod_http_bind.erl index 1dba7d193..edd9fa08c 100644 --- a/src/web/mod_http_bind.erl +++ b/src/web/mod_http_bind.erl @@ -3,7 +3,7 @@ %%% Author : Stefan Strigler %%% Purpose : Implementation of XMPP over BOSH (XEP-0206) %%% Created : Tue Feb 20 13:15:52 CET 2007 -%%% Id : $Id: mod_http_bind.erl 156 2007-06-25 09:22:57Z cromain $ +%%% Id : $Id: mod_http_bind.erl 412 2007-11-15 10:10:09Z mremond $ %%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------