Page 1 of 1

TS3.5.x: SQL для замены одного пользователя другим

PostPosted: Tue Aug 26, 2008 1:48 pm
by mvasenkov
/* мышки, станьте ежиками */
update gr_filter set filter_owner='ежик' where filter_owner='мышка';
update gr_message set message_submitter='ежик' where message_submitter='мышка';
update gr_prstatus set prstatus_user='ежик' where prstatus_user='мышка';
update gr_report set report_owner='ежик' where report_owner='мышка';
update gr_task set task_submitter='ежик' where task_submitter='мышка';
update gr_udf set udf_initialuser='ежик' where udf_initialuser='мышка';
update gr_udfsource set udfsource_user='ежик' where udfsource_user='мышка';
update gr_udfval set udfval_user='ежик' where udfval_user='мышка';
update gr_mailimport set mailimport_owner='ежик' where mailimport_owner='мышка';
update gr_emailtype set emailtype_user='ежик' where emailtype_user='мышка';
update gr_acl set acl_owner='ежик' where acl_owner='мышка';
update gr_acl set acl_to_user='ежик' where acl_to_user='мышка';
update gr_registration set registration_user='ежик' where registration_user='мышка';
update gr_script set script_owner='ежик' where script_owner='мышка';
update gr_attachment set attachment_user='ежик' where attachment_user='мышка';

update gr_message set message_handler=(select usersource_id from gr_usersource where usersource_user='ежик') where message_handler=(select usersource_id from gr_usersource where usersource_user='мышка');
update gr_subscriber set subscriber_user=(select usersource_id from gr_usersource where usersource_user='ежик') where subscriber_user=(select usersource_id from gr_usersource where usersource_user='мышка');
update gr_task set task_handler=(select usersource_id from gr_usersource where usersource_user='ежик') where task_handler=(select usersource_id from gr_usersource where usersource_user='мышка');
update gr_notification set notification_user=(select usersource_id from gr_usersource where usersource_user='ежик') where notification_user=(select usersource_id from gr_usersource where usersource_user='мышка');
update gr_acl set acl_usersource=(select usersource_id from gr_usersource where usersource_user='ежик') where acl_usersource=(select usersource_id from gr_usersource where usersource_user='мышка');

delete from gr_usersource where usersource_user='мышка';
delete from gr_currentfilter where currentfilter_user='мышка';