From 06490196eaf3873f9ecf1d3e4a7f6187c234dd17 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Sat, 14 Nov 2009 00:37:19 +0100 Subject: [PATCH] Adds support for database tablename prefixes in the account branch. Signed-off-by: Vincent Zanotti --- classes/group.php | 4 ++-- classes/platallogger.php | 2 +- upgrade/account/02_forums.sql | 30 +++++++++++++++--------------- upgrade/account/upgrade.sh | 19 ++++++++++++++----- upgrade/newdirectory-0.0.1/update.sh | 6 +----- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/classes/group.php b/classes/group.php index c75191b..8512d84 100644 --- a/classes/group.php +++ b/classes/group.php @@ -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; diff --git a/classes/platallogger.php b/classes/platallogger.php index 9ff2e61..000c09b 100644 --- a/classes/platallogger.php +++ b/classes/platallogger.php @@ -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. diff --git a/upgrade/account/02_forums.sql b/upgrade/account/02_forums.sql index 26f18f4..319d3d2 100644 --- a/upgrade/account/02_forums.sql +++ b/upgrade/account/02_forums.sql @@ -11,27 +11,27 @@ ## 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; diff --git a/upgrade/account/upgrade.sh b/upgrade/account/upgrade.sh index e9658df..d55aee2 100644 --- a/upgrade/account/upgrade.sh +++ b/upgrade/account/upgrade.sh @@ -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 diff --git a/upgrade/newdirectory-0.0.1/update.sh b/upgrade/newdirectory-0.0.1/update.sh index cbdc91e..f27da2c 100755 --- a/upgrade/newdirectory-0.0.1/update.sh +++ b/upgrade/newdirectory-0.0.1/update.sh @@ -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 - -########################################################### - -- 2.1.4