From: Greg Burri Date: Mon, 5 May 2008 20:28:52 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 1.0.0^2~107 X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=218e748e517e9b88c6bcb2eb88ed28cd536b3d4e;p=euphorik.git --- diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl deleted file mode 100755 index 7703bd3..0000000 --- a/modules/erl/euphorik_bd.erl +++ /dev/null @@ -1,142 +0,0 @@ -% Module de création de la base de données euphorik. -% @author G.Burri - --module(euphorik_bd). --export([ - create/0, - create_tables/0, - vers_version/1, - peupler/0 - ]). - --include("../include/euphorik_bd.hrl"). - - -% Instructions pour créer une nouvelle base : -% $erl -sname yaws -mnesia dir '"/projets/euphorik/BD"' -% voir doc/installation.txt -% >l(euphorik_bd). -% >euphorik_bd:create(). -create() -> - mnesia:stop(), - mnesia:delete_schema([node()]), - mnesia:create_schema([node()]), % nécessaire pour les tables sur disc - mnesia:start(), - create_tables(). - - -create_tables() -> - mnesia:create_table(counter, [ - {attributes, record_info(fields, counter)}, - {disc_copies, [node()]} - ]), - mnesia:create_table(minichat, [ - {attributes, record_info(fields, minichat)}, - {index, [auteur_id]}, - {disc_copies, [node()]} - ]), - mnesia:create_table(reponse_minichat, [ - {type, bag}, - {attributes, record_info(fields, reponse_minichat)}, - {index, [cible]}, - {disc_copies, [node()]} - ]), - mnesia:create_table(user, [ - {attributes, record_info(fields, user)}, - {index, [cookie, login]}, - {disc_copies, [node()]} - ]), - mnesia:create_table(ip_table, [ - {attributes, record_info(fields, ip_table)}, - {disc_copies, [node()]} - ]), - mnesia:create_table(troll, [ - {attributes, record_info(fields, troll)}, - {disc_copies, [node()]} - ]). - - -vers_version(2) -> - mnesia:transform_table( - user, - fun({user, Id, Cookie, Pseudo, Date_creation, Date_derniere_connexion, Css}) -> - {user, Id, Cookie, Pseudo, "", "", "", Date_creation, Date_derniere_connexion, Css} - end, - record_info(fields, user), - user - ); -vers_version(3) -> - mnesia:transform_table( - user, - fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css}) -> - {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, 0} - end, - record_info(fields, user), - user - ); -vers_version(4) -> - mnesia:transform_table( - user, - fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Indice_flood}) -> - {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Indice_flood, []} - end, - record_info(fields, user), - user - ); -% Ajout du numéro de page de la conv principale -vers_version(5) -> - mnesia:transform_table( - user, - fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Indice_flood, Conversations}) -> - {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Indice_flood, 1, Conversations} - end, - record_info(fields, user), - user - ); -% Ajout le format d'affichage des pseudos -vers_version(6) -> - mnesia:transform_table( - user, - fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Indice_flood, Page_Principale, Conversations}) -> - {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, nick, Indice_flood, Page_Principale, Conversations} - end, - record_info(fields, user), - user - ); -% Ajout de la table 'ip_table' -% Ajout du statut 'ek_master' pour les users -vers_version(7) -> - mnesia:transform_table( - user, - fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Nick_format, Indice_flood, Page_Principale, Conversations}) -> - {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Nick_format, Indice_flood, Page_Principale, Conversations, false, undefined} - end, - record_info(fields, user), - user - ), - mnesia:create_table(ip_table, [ - {attributes, record_info(fields, ip_table)}, - {disc_copies, [node()]} - ]), - mnesia:create_table(troll, [ - {attributes, record_info(fields, troll)}, - {disc_copies, [node()]} - ]); -vers_version(8) -> - mnesia:transform_table( - ip_table, - fun() -> null end, - record_info(fields, ip_table), - ip_table - ). - - - -% exemple de peuplage de la BD, utilisé pour les tests -peupler() -> - mnesia:transaction( - fun() -> - mnesia:write({minichat, now(), "Pierre", "Salut tout le monde"}), - mnesia:write({minichat, now(), "Paul", "Salut à toi !"}) - end - ).