+++ /dev/null
-# Move forums tables to x4dat
-#RENAME forums.list
-# TO x4dat.forums;
-#RENAME forums.abos
-# TO x4dat.forum_subs;
-#RENAME forums.innd
-# TO x4dat.forum_innd;
-#RENAME forums.porfils
-# TO x4dat.forum_profiles;
-#DROP DATABASE forums;
-
-## Dev version of previous line
-# (non destructive)
-CREATE TABLE #x4dat#.forums
- LIKE #forums#.list;
-INSERT INTO #x4dat#.forums
- SELECT *
- FROM #forums#.list;
-
-CREATE TABLE #x4dat#.forum_subs
- LIKE #forums#.abos;
-INSERT INTO #x4dat#.forum_subs
- SELECT *
- FROM #forums#.abos;
-
-CREATE TABLE #x4dat#.forum_innd
- LIKE #forums#.innd;
-INSERT INTO #x4dat#.forum_innd
- SELECT *
- FROM #forums#.innd;
-
-CREATE TABLE #x4dat#.forum_profiles
- LIKE forums#.profils;
-INSERT INTO #x4dat#.forum_profiles
- SELECT *
- FROM forums.profils;
-
-
-# Conform to naming convention.
- ALTER TABLE forums
-CHANGE COLUMN nom name VARCHAR(64) NOT NULL;
-
- ALTER TABLE forum_profiles
-CHANGE COLUMN nom name VARCHAR(64) NOT NULL,
- ADD COLUMN last_seen TIMESTAMP NOT NULL DEFAULT '0000-00-00';
-
-# vim:set syntax=mysql:
+++ /dev/null
-CREATE TABLE log_actions
- LIKE logger.actions;
- INSERT INTO log_actions
- SELECT *
- FROM logger.actions;
-
-CREATE TABLE log_events
- LIKE logger.events;
- INSERT INTO log_events
- SELECT *
- FROM logger.events;
-
-CREATE TABLE log_last_sessions
- LIKE logger.last_sessions;
- INSERT INTO log_last_sessions
- SELECT *
- FROM logger.last_sessions;
-
-CREATE TABLE log_sessions
- LIKE logger.sessions;
- INSERT INTO log_sessions
- SELECT *
- FROM logger.sessions;
-
-# vim:set ft=mysql:
+++ /dev/null
-CREATE TABLE payment_codeC
- LIKE paiement.codeC;
- INSERT INTO payment_codeC
- SELECT *
- FROM paiement.codeC;
-
-CREATE TABLE payment_codeRCB
- LIKE paiement.codeRCB;
- INSERT INTO payment_codeRCB
- SELECT *
- FROM paiement.codeRCB;
-
-CREATE TABLE payment_methods
- LIKE paiement.methodes;
- INSERT INTO payment_methods
- SELECT *
- FROM paiement.methodes;
-
-CREATE TABLE payments
- LIKE paiement.paiements;
- INSERT INTO payments
- SELECT *
- FROM paiement.paiements;
-
-CREATE TABLE payment_transactions
- LIKE paiement.transactions;
- INSERT INTO payment_transactions
- SELECT *
- FROM paiement.transactions;
-
-# Conform to naming convention
- ALTER TABLE payments
-CHANGE COLUMN montant_def amount_def DECIMAL(10,2) NOT NULL DEFAULT 0.00,
-CHANGE COLUMN montant_min amount_min DECIMAL(10,2) NOT NULL DEFAULT 0.00,
-CHANGE COLUMN montant_max amount_max DECIMAL(10,2) NOT NULL DEFAULT 0.00;
-
- ALTER TABLE payment_transactions
-CHANGE COLUMN montant amount VARCHAR(15) NOT NULL DEFAULT '0.00',
-CHANGE COLUMN cle pkey VARCHAR(5) NOT NULL;
-
-# vim:set ft=mysql:
+++ /dev/null
-CREATE TABLE group_announces
- LIKE groupex.announces;
- INSERT INTO group_announces
- SELECT *
- FROM groupex.announces;
-
-CREATE TABLE group_announces_photo
- LIKE groupex.announces_photo;
- INSERT INTO group_announces_photo
- SELECT *
- FROM groupex.announces_photo;
-
-CREATE TABLE group_announces_read
- LIKE groupex.announces_read;
- INSERT INTO group_announces_read
- SELECT *
- FROM groupex.announces_read;
-
-CREATE TABLE groups
- LIKE groupex.asso;
- INSERT INTO groups
- SELECT *
- FROM groupex.asso;
-
-CREATE TABLE group_dom
- LIKE groupex.dom;
- INSERT INTO group_dom
- SELECT *
- FROM groupex.dom;
-
-CREATE TABLE group_events
- LIKE groupex.evenements;
- INSERT INTO group_events
- SELECT *
- FROM groupex.evenements;
-
-CREATE TABLE group_event_items
- LIKE groupex.evenements_items;
- INSERT INTO group_event_items
- SELECT *
- FROM groupex.evenements_items;
-
-CREATE TABLE group_event_participants
- LIKE groupex.evenements_participants;
- INSERT INTO group_event_participants
- SELECT *
- FROM groupex.evenements_participants;
-
-CREATE TABLE group_members
- LIKE groupex.membres;
- INSERT INTO group_members
- SELECT *
- FROM groupex.membres;
-
-CREATE TABLE group_member_sub_requests
- LIKE groupex.membres_sub_requests;
- INSERT INTO group_member_sub_requests
- SELECT *
- FROM groupex.membres_sub_requests;
-
-CREATE TABLE group_auth
- LIKE x4dat.groupesx_auth;
- INSERT INTO group_auth
- SELECT *
- FROM x4dat.groupesx_auth;
-
-# vim:set ft=mysql:
+++ /dev/null
-CREATE TABLE profile_photos
- LIKE photo;
- INSERT INTO profile_photos
- SELECT *
- FROM photo;
-
- ALTER TABLE profile_photos
-CHANGE COLUMN uid pid INT(6) not null;
-
-
-# vim:set ft=mysql:
--- /dev/null
+# forums
+ ALTER TABLE forums
+CHANGE COLUMN nom name VARCHAR(64) NOT NULL;
+
+ ALTER TABLE forum_profiles
+CHANGE COLUMN nom name VARCHAR(64) NOT NULL,
+ ADD COLUMN last_seen TIMESTAMP NOT NULL DEFAULT '0000-00-00';
+
+# payment
+ ALTER TABLE payments
+CHANGE COLUMN montant_def amount_def DECIMAL(10,2) NOT NULL DEFAULT 0.00,
+CHANGE COLUMN montant_min amount_min DECIMAL(10,2) NOT NULL DEFAULT 0.00,
+CHANGE COLUMN montant_max amount_max DECIMAL(10,2) NOT NULL DEFAULT 0.00;
+
+ ALTER TABLE payment_transactions
+CHANGE COLUMN montant amount VARCHAR(15) NOT NULL DEFAULT '0.00',
+CHANGE COLUMN cle pkey VARCHAR(5) NOT NULL;
+
+# photo
+ ALTER TABLE profile_photos
+CHANGE COLUMN uid pid INT(6) not null;
+
+# vim:set ft=mysql:
IF(q.core_mail_fmt = 'html', 'html', 'text') AS email_format,
q.skin AS skin,
q.last_version AS last_version
- from auth_user_md5 as u
- left join auth_user_quick as q on (q.user_id = u.user_id)
+ from #x4dat#.auth_user_md5 as u
+ left join #x4dat#.auth_user_quick as q on (q.user_id = u.user_id)
where hruid is not null;
# Insert carnet-relative data
IF(ws3.cid IS NULL, '', 'death'), ',',
IF(ws4.cid IS NULL, '', 'birthday')) AS actions,
q.watch_last as last
- from auth_user_quick as q
- left join watch_sub as ws1 on (ws1.uid = q.user_id and ws1.cid = 1)
- left join watch_sub as ws2 on (ws2.uid = q.user_id and ws2.cid = 2)
- left join watch_sub as ws3 on (ws3.uid = q.user_id and ws3.cid = 3)
- left join watch_sub as ws4 on (ws4.uid = q.user_id and ws4.cid = 4);
+ from #x4dat#.auth_user_quick as q
+ left join #x4dat#.watch_sub as ws1 on (ws1.uid = q.user_id and ws1.cid = 1)
+ left join #x4dat#.watch_sub as ws2 on (ws2.uid = q.user_id and ws2.cid = 2)
+ left join #x4dat#.watch_sub as ws3 on (ws3.uid = q.user_id and ws3.cid = 3)
+ left join #x4dat#.watch_sub as ws4 on (ws4.uid = q.user_id and ws4.cid = 4);
# Insert carvas
insert into carvas
select user_id, redirecturl
- from auth_user_quick
+ from #x4dat#.auth_user_quick
where LENGTH(redirecturl) > 0;
# Insert all existing profiles
IF(q.emails_alias_pub = 'public', 'public', 'private') AS alias_pub,
u.nationalite AS nationality1, u.nationalite2 AS nationality2,
u.nationalite3 AS nationality3, u.date AS last_change
- from auth_user_md5 AS u
- left join auth_user_quick AS q ON (u.user_id = q.user_id)
+ from #x4dat#.auth_user_md5 AS u
+ left join #x4dat#.auth_user_quick AS q ON (u.user_id = q.user_id)
where u.hruid is not null;
# Add associations account <-> profile
insert into account_profiles
select user_id AS uid, user_id AS pid, 'owner' AS perms
- from auth_user_md5
+ from #x4dat#.auth_user_md5
where hruid is not null;
# Update banana last_seen timetamp
update forum_profiles as fp
-inner join auth_user_quick as q ON (q.user_id = fp.uid)
+inner join #x4dat#.auth_user_quick as q ON (q.user_id = fp.uid)
set fp.uid = fp.uid, fp.tree_unread = fp.tree_unread, fp.tree_read = fp.tree_read,
fp.last_seen = q.banana_last;
insert ignore into forum_profiles (uid, last_seen)
select user_id as uid, banana_last as last_seen
- from auth_user_quick
+ from #x4dat#.auth_user_quick
where banana_last >= DATE_SUB(NOW(), INTERVAL 6 MONTH);
# Mail storage has been moved out of account settings
insert into email_options
select user_id as uid, mail_storage as storage
- from auth_user_md5;
+ from #x4dat#.auth_user_md5;
# vim:set syntax=mysql:
--- /dev/null
+#!/usr/bin/php5 -q
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2010 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+require('./connect.db.inc.php');
+
+function copyTable($source, $target)
+{
+ XDB::execute('CREATE TABLE ' . $target . '
+ LIKE ' . $source);
+ XDB::execute('INSERT INTO ' . $target . '
+ SELECT *
+ FROM ' . $source);
+}
+
+copyTable('#forums#.list', 'forums');
+copyTable('#forums#.abos', 'forum_subs');
+copyTable('#forums#.innd', 'forum_innd');
+copyTable('#forums#.profils', 'forum_profiles');
+
+copyTable('#logger#.actions', 'log_actions');
+copyTable('#logger#.events', 'log_events');
+copyTable('#logger#.last_sessions', 'log_last_sessions');
+copyTable('#logger#.sessions', 'log_sessions');
+
+copyTable('#paiement#.paiements', 'payments');
+copyTable('#paiement#.codeC', 'payment_codeC');
+copyTable('#paiement#.codeRCB', 'payment_codeRCB');
+copyTable('#paiement#.methodes', 'payment_methods');
+copyTable('#paiement#.transactions', 'payment_transactions');
+
+copyTable('#groupex#.announces', 'group_announces');
+copyTable('#groupex#.announces_photo', 'group_announces_photo');
+copyTable('#groupex#.announces_read', 'group_announces_read');
+copyTable('#groupex#.asso', 'groups');
+copyTable('#groupex#.dom', 'group_dom');
+copyTable('#groupex#.evenements', 'group_events');
+copyTable('#groupex#.evenements_items', 'group_event_items');
+copyTable('#groupex#.evenements_participants', 'group_event_participants');
+copyTable('#groupex#.membres', 'group_members');
+copyTable('#groupex#.membres_sub_requests', 'group_member_sub_requests');
+copyTable('#x4dat#.groupesx_auth'), 'group_auth');
+
+copyTable('#x4dat#.photo', 'profile_photos');
+
+copyTable('#x4dat#.search_autocomplete', 'search_autocomplete');
+copyTable('#x4dat#.register_marketing', 'register_marketing');
+copyTable('#x4dat#.watch_profile', 'watch_profile');
+
+// Should be renamed to geoloc_country
+copyTable('#x4dat#.geoloc_pays', 'geoloc_pays');
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
. ../inc/pervasive.sh
###########################################################
+echo "Setting up new database: target db is $DATABASE, source prefix is $DBPREFIX"
+echo -n "* copying tables"
+./copy_tables.php || die "ERROR"
+echo " OK"
+
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 .
+ echo -n "* running $sql"
+ (sed -e "s/#\([0-9a-z]*\)#/${DBPREFIX}\1/g" < $sql | $MYSQL $DATABASE &>/dev/null) || die "ERROR"
+ echo " OK"
done
###########################################################
fi
declare -r DATABASE="${DBPREFIX}x4dat"
+function die() {
+ echo $1
+ exit 1
+}
+
function mailman_stop() {
echo -n "stops mailman"
/etc/init.d/mailman stop &>/dev/null
CONCAT(IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom), ' ', u.prenom),
CONCAT(u.prenom, ' ', IF(u.nom_usage != '', u.nom_usage, u.nom)),
CONCAT(IF(u.nom_usage != '', u.nom_usage, u.nom), ' ', u.prenom)
- FROM auth_user_md5 AS u
- LEFT JOIN auth_user_quick AS q ON (u.user_id = q.user_id);
+ FROM #x4dat#.auth_user_md5 AS u
+ LEFT JOIN #x4dat#.auth_user_quick AS q ON (u.user_id = q.user_id);
DROP TABLE IF EXISTS profile_name_enum;
INSERT INTO profile_name (pid, name, typeid)
SELECT u.user_id, u.nom, e.id
- FROM auth_user_md5 AS u
+ FROM #x4dat#.auth_user_md5 AS u
INNER JOIN profile_name_enum AS e ON (e.name = 'Nom patronymique')
WHERE nom != '';
INSERT INTO profile_name (pid, name, typeid)
SELECT u.user_id, u.nom_ini, e.id
- FROM auth_user_md5 AS u
+ FROM #x4dat#.auth_user_md5 AS u
INNER JOIN profile_name_enum AS e ON (e.name = 'Nom initial')
WHERE nom_ini != '';
INSERT INTO profile_name (pid, name, typeid)
SELECT u.user_id, u.prenom, e.id
- FROM auth_user_md5 AS u
+ FROM #x4dat#.auth_user_md5 AS u
INNER JOIN profile_name_enum AS e ON (e.name = 'Prénom')
WHERE prenom != '';
INSERT INTO profile_name (pid, name, typeid)
SELECT u.user_id, u.prenom_ini, e.id
- FROM auth_user_md5 AS u
+ FROM #x4dat#.auth_user_md5 AS u
INNER JOIN profile_name_enum AS e ON (e.name = 'Prénom initial')
WHERE prenom_ini != '';
INSERT INTO profile_name (pid, name, typeid)
SELECT u.user_id, u.nom_usage, e.id
- FROM auth_user_md5 AS u
+ FROM #x4dat#.auth_user_md5 AS u
INNER JOIN profile_name_enum AS e ON (e.name = 'Nom usuel')
WHERE nom_usage != '';
INSERT INTO profile_name (pid, name, typeid)
SELECT q.user_id, q.profile_nick, e.id
- FROM auth_user_quick AS q
+ FROM #x4dat#.auth_user_quick AS q
INNER JOIN profile_name_enum AS e ON (e.name = 'Surnom')
WHERE profile_nick != '';
+++ /dev/null
-ALTER TABLE `adresses` ADD `comment` varchar(100) NOT NULL;
-
INSERT INTO `profile_networking` (`uid`, `nwid`, `network_type`, `address`, `pub`)
SELECT `user_id`, 0, 0, `profile_web`, `profile_web_pub`
- FROM `auth_user_quick`
+ FROM #x4dat#.`auth_user_quick`
WHERE `profile_web` <> "";
-- Modify watch_profile to update 'field' from web to networking
'networking', 'appli1', 'appli2', 'addresses',
'section', 'binets', 'medals', 'cv', 'jobs', 'photo');
--- Drop old web URL columns
-ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web`;
-ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web_pub`;
-
# vim:set syntax=mysql:
+++ /dev/null
-ALTER TABLE auth_user_md5 ADD COLUMN nationalite2 CHAR(2) DEFAULT NULL,
- ADD COLUMN nationalite3 CHAR(2) DEFAULT NULL,
- ADD KEY nationalite2 (nationalite2),
- ADD KEY nationalite3 (nationalite3),
- MODIFY nationalite CHAR(2) DEFAULT NULL;
-
-UPDATE auth_user_md5 SET nationalite=NULL WHERE nationalite="00" OR nationalite='';
-
-DELETE FROM geoloc_pays WHERE a2="00";
-
-ALTER TABLE watch_profile MODIFY field enum('nom', 'freetext', 'mobile', 'nationalite', 'nationalite2', 'nationalite3',
- 'nick', 'web', 'networking', 'appli1', 'appli2', 'addresses',
- 'section', 'binets', 'medals', 'cv', 'jobs', 'photo');
-
-# vim:set syntax=mysql:
INSERT INTO profile_education_degree (eduid, degreeid)
SELECT a.id, d.id
- FROM applis_def AS a
+ FROM #x4dat#.applis_def AS a
INNER JOIN profile_education_degree_enum AS d ON (FIND_IN_SET(d.degree, a.type));
INSERT INTO profile_education_enum (id, name, url)
SELECT id, text, url
- FROM applis_def;
+ FROM #x4dat#.applis_def;
INSERT INTO profile_education (id, uid, eduid, degreeid)
SELECT a.ordre, a.uid, a.aid, d.id
- FROM applis_ins AS a
+ FROM #x4dat#.applis_ins AS a
INNER JOIN profile_education_degree_enum AS d ON (a.type = d.degree);
UPDATE watch_profile AS w1
UPDATE watch_profile SET field = 'edus' WHERE field = 'appli1';
+
DELETE FROM watch_profile WHERE field = 'appli2';
ALTER TABLE watch_profile MODIFY field enum('nom', 'freetext', 'mobile', 'nationalite', 'nationalite2',
INSERT IGNORE INTO profile_job_enum (name, url)
SELECT entreprise, web
- FROM entreprises;
+ FROM #x4dat#.entreprises;
INSERT INTO profile_job (id, uid, jobid, email, pub, email_pub, description)
SELECT e.entrid, e.uid, j.id, e.email, e.pub, e.email_pub,
CONCAT_WS(', ', IF(e.poste = '', NULL, e.poste), IF(e.fonction = 0, NULL, f.fonction_fr),
IF(e.ss_secteur IS NULL , IF(e.secteur IS NULL, NULL, s.label), ss.label))
- FROM entreprises AS e
+ FROM #x4dat#.entreprises AS e
INNER JOIN profile_job_enum AS j ON (e.entreprise = j.name)
- LEFT JOIN fonctions_def AS f ON (f.id = e.fonction)
- LEFT JOIN emploi_ss_secteur AS ss ON (ss.id = e.ss_secteur)
- LEFT JOIN emploi_secteur AS s ON (s.id = e.secteur);
+ LEFT JOIN #x4dat#.fonctions_def AS f ON (f.id = e.fonction)
+ LEFT JOIN #x4dat#.emploi_ss_secteur AS ss ON (ss.id = e.ss_secteur)
+ LEFT JOIN #x4dat#.emploi_secteur AS s ON (s.id = e.secteur);
-- vim:set syntax=mysql:
INSERT INTO profile_mentor (uid, expertise)
SELECT uid, expertise
- FROM mentor;
+ FROM #x4dat#.mentor;
CREATE TABLE IF NOT EXISTS profile_mentor_country (
uid INT(11) NOT NULL DEFAULT 0,
INSERT INTO profile_mentor_country (uid, country)
SELECT uid, pid
- FROM mentor_pays;
+ FROM #x4dat#.mentor_pays;
CREATE TABLE IF NOT EXISTS profile_mentor_sector (
uid INT(11) NOT NULL DEFAULT 0,
IF(FIND_IN_SET('courrier', 'statut'), 'mail,', ''),
IF(FIND_IN_SET('active', 'statut'), 'current,', ''),
IF(FIND_IN_SET('temporaire', 'statut'), 'temporary', ''))
- FROM adresses;
+ FROM #x4dat#.adresses;
CREATE TABLE IF NOT EXISTS geoloc_countries (
iso_3166_1_a2 CHAR(2) NOT NULL,
phonePrefix, phoneFormat, licensePlate)
SELECT a2, a3, n3, worldrgn, pays, country, capital, nat, phoneprf, phoneformat, license_plate
FROM geoloc_pays;
+DROP TABLE geoloc_pays;
CREATE TABLE IF NOT EXISTS geoloc_administrativeareas (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,