Skip to content

GOKb Live Server Migration

Ian Ibbotson edited this page Oct 6, 2016 · 5 revisions

users (from Mysql)

Set up a data file called users.sql

select max(id) id,
   max(account_expired+0) expired,
   max(account_locked+0) locked,
   max(enabled+0) enabled,
   max(password) password,
   max(password_expired+0) expired,
   max(username) username,
   max(display_name) display_name,
   max(email) email,
   max(default_page_size) default_page_size,
   max(r1.rdv_value) show_info_icon,
   max(r2.rdv_value) show_quick_view,
   max(kbc_name) kbc_name,
   max(adm_r.authority) admin_authority,
   max(user_r.authority) user_authority,
   max(ctrb_r.authority) contributor_authority,
   max(api_r.authority) api_authority,
   max(ru_r.authority) refine_user_authority,
   max(rt_r.authority) refine_tester_authority,
   max(ed_r.authority) editor_authority
from user left outer join kbcomponent on (org_id = kbc_id)
      left outer join refdata_value as r1 on (show_info_icon_id = r1.rdv_id)
      left outer join refdata_value as r2 on (show_quick_view_id = r2.rdv_id)
      left outer join user_role as adm_ur on (user.id = adm_ur.user_id)
      left outer join role as adm_r on ( adm_ur.role_id = adm_r.role_id and adm_r.authority='ROLE_ADMIN')
      left outer join user_role as user_ur on (user.id = user_ur.user_id)
      left outer join role as user_r on ( user_ur.role_id = user_r.role_id and user_r.authority='ROLE_USER')
      left outer join user_role as ctrb_ur on (user.id = ctrb_ur.user_id)
      left outer join role as ctrb_r on ( ctrb_r.role_id = ctrb_ur.role_id and ctrb_r.authority='ROLE_CONTRIBUTOR' )
      left outer join user_role as api_ur on (user.id = api_ur.user_id )
      left outer join role as api_r on ( api_r.role_id = api_ur.role_id and api_r.authority='ROLE_API')
      left outer join user_role as ru_ur on (user.id = ru_ur.user_id)
      left outer join role as ru_r on ( ru_r.role_id = ru_ur.role_id and ru_r.authority='ROLE_REFINEUSER')
      left outer join user_role as rt_ur on (user.id = rt_ur.user_id)
      left outer join role as rt_r on ( rt_r.role_id = rt_ur.role_id and rt_r.authority='ROLE_REFINEUSER')
      left outer join user_role as ed_ur on (user.id = ed_ur.user_id)
      left outer join role as ed_r on ( ed_r.role_id = ed_ur.role_id and ed_r.authority='ROLE_EDITOR')
group by user.id

and run

mysql -u gokb -pPPh7WfYqEsdK gokbLive < ./users.sql > users.tsv

To generate a tsv of the users in the current system. N.B. this file does not contain passwords but it does contain hashed passwords - which can be used to brute force (or rainbow table) attack weak passwords. Care should be taken not to loose this file - and delete it as soon as you are done with it.

Take the .tsv and run it through the user import process - tba