auth_user_md5 -> accounts conversion script.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 7 Dec 2008 16:55:33 +0000 (17:55 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 7 Dec 2008 16:55:33 +0000 (17:55 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
upgrade/account/00_account.sql
upgrade/account/01_account_insertion.sql [new file with mode: 0644]

index 89c8d47..94013bb 100644 (file)
@@ -17,7 +17,8 @@ CREATE TABLE accounts (
   comment varchar(255) default null,
 
   # User settings
-  name varchar(255) default null,
+  full_name varchar(255) default null,
+  display_name varchar(255) default null,
   sex enum('female', 'male') not null default 'male',
   mail_format enum('plain', 'html') not null default 'html',
   skin varchar(32) default null,
diff --git a/upgrade/account/01_account_insertion.sql b/upgrade/account/01_account_insertion.sql
new file mode 100644 (file)
index 0000000..2673de8
--- /dev/null
@@ -0,0 +1,26 @@
+insert into account_types
+     values ('x', 'mail,groups,forums,list,search,portal');
+
+insert into accounts
+     select u.user_id AS uid, hruid AS hruid, 'x' AS type,
+            perms = 'admin' AS is_admin,
+            IF(perms = 'admin' or perms = 'user', 'active', perms) AS state,
+            IF(LENGTH(password) = 40, password, NULL) AS password,
+            date_ins AS registration_date,
+            IF(FIND_IN_SET('watch', flags), 'watch', '') AS flags,
+            IF(LENGTH(comment) > 0, comment, NULL) AS comment,
+            CONCAT(prenom, ' ', IF (nom_usage != '' and nom_usage IS NOT NULL, nom_usage, nom)) AS full_name,
+            prenom AS display_name,
+            IF(FIND_IN_SET('femme', flags), 'female', 'male') AS sex,
+            IF(q.core_mail_fmt = 'html', 'html', 'plain') AS mail_format,
+            q.skin AS skin
+       from auth_user_md5 as u
+  left join auth_user_quick as q on (q.user_id = u.user_id)
+      where hruid is not null;
+
+insert into account_profiles
+     select user_id AS uid, user_id AS pid, 'owner' AS perms
+       from auth_user_md5
+      where hruid is not null;
+
+# vim:set syntax=mysql: