1 #
Create a
type 'X' with all permissions
2 insert into account_types
3 values ('x', 'mail,groups,forums,list,search,portal');
5 #
Insert all existing accounts
7 select u.user_id
AS uid
, hruid
AS hruid
, 'x' AS type,
8 perms
= 'admin' AS is_admin
,
9 IF(perms
= 'admin' or perms
= 'user', 'active', perms
) AS state,
10 IF(LENGTH(password) = 40, password, NULL) AS password,
11 IF(LENGTH(q.core_rss_hash
) > 0, q.core_rss_hash
, NULL) AS token,
12 IF(LENGTH(smtppass
) = 0, NULL, smtppass
) AS weak_password
,
13 date_ins
AS registration_date
,
14 IF(FIND_IN_SET('watch', flags
), 'watch', '') AS flags
,
15 IF(LENGTH(comment) > 0, comment, NULL) AS comment,
16 CONCAT(prenom
, ' ', IF (nom_usage
!= '' and nom_usage
IS NOT NULL, nom_usage
, nom
)) AS full_name
,
17 prenom
AS display_name
,
18 IF(FIND_IN_SET('femme', flags
), 'female', 'male') AS sex
,
19 IF(q.core_mail_fmt
= 'html', 'html', 'text') AS email_format
,
21 q.last_version
AS last_version
22 from auth_user_md5
as u
23 left join auth_user_quick
as q
on (q.user_id
= u.user_id
)
24 where hruid
is not null;
26 #
Insert carnet
-relative data
28 select user_id
as uid
, watch_flags
as flags
, watch_last
as last
33 select user_id
, redirecturl
35 where LENGTH(redirecturl
) > 0;
37 #
Insert all existing profiles
39 select u.user_id
AS pid
, u.hruid
AS hrpid
, u.matricule
AS xorg_id
,
40 u.matricule_ax
AS ax_id
, u.naissance
AS birthdate
, u.naissance_ini
AS birthdate_ref
,
41 IF(u.deces
= 0, NULL, u.deces
) AS deathdate
,
42 IF(FIND_IN_SET('femme', flags
), 'female', 'male') AS sex
,
43 IF(u.
section = 0, NULL, u.
section) AS section,
44 IF(LENGTH(u.cv
) > 0, u.cv
, NULL) AS cv
,
45 IF(LENGTH(q.profile_freetext
) > 0, q.profile_freetext
, NULL) AS freetext
,
46 IF(q.profile_freetext_pub
= 'public', 'public', 'private') AS freetext_pub
,
47 IF(q.profile_medals_pub
= 'public', 'public', 'private') AS medals_pub
,
48 IF(q.emails_alias_pub
= 'public', 'public', 'private') AS alias_pub
,
49 u.nationalite
AS nationality1
, u.nationalite2
AS nationality2
,
50 u.nationalite3
AS nationality3
, u.
date AS last_change
51 from auth_user_md5
AS u
52 left join auth_user_quick
AS q
ON (u.user_id
= q.user_id
)
53 where u.hruid
is not null;
55 #
Add associations account
<-> profile
56 insert into account_profiles
57 select user_id
AS uid
, user_id
AS pid
, 'owner' AS perms
59 where hruid
is not null;
61 #
Update banana last_seen timetamp
62 update forum_profiles
as fp
63 inner join auth_user_quick
as q
ON (q.user_id
= fp.uid
)
64 set fp.uid
= fp.uid
, fp.tree_unread
= fp.tree_unread
, fp.tree_read
= fp.tree_read
,
65 fp.last_seen
= q.banana_last
;
67 insert ignore into forum_profiles (uid
, last_seen
)
68 select user_id
as uid
, banana_last
as last_seen
70 where banana_last
>= DATE_SUB(NOW(), INTERVAL 6 MONTH);
72 # Mail
storage has been moved
out of account settings
73 insert into email_options
74 select user_id
as uid
, mail_storage
as storage
77 # vim
:set syntax
=mysql
: