From: Vincent Zanotti Date: Fri, 13 Jun 2008 00:44:15 +0000 (+0200) Subject: Adds a new 'hruid' column (Human Readable UID) to the auth_user_md5 table. X-Git-Tag: xorg/0.10.0~86^2~95 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=92b37ea34a8b1c7cf25280506d52108d9c0eff50;hp=edbf7d44136018a9e1732da6ac0c21f0590f4651;p=platal.git Adds a new 'hruid' column (Human Readable UID) to the auth_user_md5 table. Adds hruid migration scripts. Signed-off-by: Vincent Zanotti --- diff --git a/upgrade/0.9.17/03_hruid.sql b/upgrade/0.9.17/03_hruid.sql new file mode 100644 index 0000000..49b0f78 --- /dev/null +++ b/upgrade/0.9.17/03_hruid.sql @@ -0,0 +1,13 @@ +# Creates a new column for the hruid field, and adds an index on it. +ALTER TABLE auth_user_md5 + ADD COLUMN hruid VARCHAR(255) DEFAULT NULL AFTER user_id, + ADD UNIQUE INDEX hruid(hruid); + + +# Pre-fills the hruid field with the current forlife. + UPDATE auth_user_md5 AS u +LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie') + SET u.hruid = a.alias + WHERE a.alias IS NOT NULL AND u.hruid IS NULL; + +# vim:set syntax=mysql: diff --git a/upgrade/0.9.17/connect.db.inc.php b/upgrade/0.9.17/connect.db.inc.php new file mode 100644 index 0000000..2e66895 --- /dev/null +++ b/upgrade/0.9.17/connect.db.inc.php @@ -0,0 +1,28 @@ + diff --git a/upgrade/0.9.17/hruid.update.php b/upgrade/0.9.17/hruid.update.php new file mode 100755 index 0000000..8edb887 --- /dev/null +++ b/upgrade/0.9.17/hruid.update.php @@ -0,0 +1,20 @@ +#!/usr/bin/php5 +next()) { + $forlife = make_forlife($prenom, $nom, $promo); + if (!XDB::execute("UPDATE auth_user_md5 SET hruid = {?} WHERE user_id = {?}", $forlife, $user_id)) { + echo "WARNING: Duplicate forlife for user $user_id and forlife '$forlife'. Please check manually the entry.\n"; + } +} +?> diff --git a/upgrade/0.9.17/update.sh b/upgrade/0.9.17/update.sh index f351939..0e99620 100755 --- a/upgrade/0.9.17/update.sh +++ b/upgrade/0.9.17/update.sh @@ -16,4 +16,9 @@ do done ########################################################### +echo "Creating forlife ids for unregistered user (takes a while)." + +./hruid.update.php + +###########################################################