Adds support for database tablename prefixes in the account branch.
authorVincent Zanotti <vincent.zanotti@m4x.org>
Fri, 13 Nov 2009 23:37:19 +0000 (00:37 +0100)
committerVincent Zanotti <vincent.zanotti@m4x.org>
Fri, 13 Nov 2009 23:37:19 +0000 (00:37 +0100)
Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
classes/group.php
classes/platallogger.php
upgrade/account/02_forums.sql
upgrade/account/upgrade.sh
upgrade/newdirectory-0.0.1/update.sh

index c75191b..8512d84 100644 (file)
@@ -84,8 +84,8 @@ class Group
         $res = XDB::query('SELECT  a.*, d.nom AS domnom,
                                    FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
                                    FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
-                             FROM  groupex.asso AS a
-                        LEFT JOIN  groupex.dom  AS d ON d.id = a.dom
+                             FROM  #groupex#.asso AS a
+                        LEFT JOIN  #groupex#.dom  AS d ON d.id = a.dom
                             WHERE  ' . $where);
         if ($res->numRows() != 1) {
             return null;
index 9ff2e61..000c09b 100644 (file)
@@ -46,7 +46,7 @@ class PlatalLogger extends PlLogger
 
         // retrieve available actions
         $this->actions = XDB::fetchAllAssoc('text', 'SELECT  id, text
-                                                       FROM  logger.actions');
+                                                       FROM  #logger#.actions');
     }
 
     /** Creates a new session entry in database and return its ID.
index 26f18f4..319d3d2 100644 (file)
 
 ## Dev version of previous line
 # (non destructive)
-CREATE TABLE  x4dat.forums
-        LIKE  forums.list;
-INSERT INTO  x4dat.forums
+CREATE TABLE  #x4dat#.forums
+        LIKE  #forums#.list;
+INSERT INTO  #x4dat#.forums
      SELECT  *
-       FROM  forums.list;
+       FROM  #forums#.list;
 
-CREATE TABLE  x4dat.forum_subs
-        LIKE  forums.abos;
-INSERT INTO  x4dat.forum_subs
+CREATE TABLE  #x4dat#.forum_subs
+        LIKE  #forums#.abos;
+INSERT INTO  #x4dat#.forum_subs
      SELECT  *
-       FROM  forums.abos;
+       FROM  #forums#.abos;
 
-CREATE TABLE  x4dat.forum_innd
-        LIKE  forums.innd;
-INSERT INTO  x4dat.forum_innd
+CREATE TABLE  #x4dat#.forum_innd
+        LIKE  #forums#.innd;
+INSERT INTO  #x4dat#.forum_innd
      SELECT  *
-       FROM  forums.innd;
+       FROM  #forums#.innd;
 
-CREATE TABLE  x4dat.forum_profiles
-        LIKE  forums.profils;
-INSERT INTO  x4dat.forum_profiles
+CREATE TABLE  #x4dat#.forum_profiles
+        LIKE  forums#.profils;
+INSERT INTO  #x4dat#.forum_profiles
      SELECT  *
        FROM  forums.profils;
 
index e9658df..d55aee2 100644 (file)
@@ -1,7 +1,16 @@
-#!/bin/sh
+#!/bin/bash
 
-echo "Upgrading database"
-mysql x4dat < *.sql
+. ../inc/pervasive.sh
 
-echo "Updating birthday date"
-php birthday.php
+###########################################################
+for sql in *.sql
+do
+    echo -n $sql
+    (sed -e "s/#\([0-9a-z]*\)#/${DBPREFIX}\1/g" < $sql | $MYSQL $DATABASE &>/dev/null) || echo -n " ERROR"
+    echo .
+done
+
+###########################################################
+echo "Updating birthday dates"
+
+./birthday.php
index cbdc91e..f27da2c 100755 (executable)
@@ -6,12 +6,11 @@ mailman_stop
 mailman_templates
 mailman_start
 
-
 ###########################################################
 for sql in *.sql
 do
     echo -n $sql
-    $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR"
+    (sed -e "s/#\([0-9a-z]*\)#/${DBPREFIX}\1/g" < $sql | $MYSQL $DATABASE &>/dev/null) || echo -n " ERROR"
     echo .
 done
 
@@ -33,6 +32,3 @@ cat
 pushd ../../bin
 ./search.rebuild_db.php
 popd
-
-###########################################################
-