-- ------------------------------------------------
-- Optimize um_user_role
-- Created 20130621
-- ------------------------------------------------

ALTER TABLE `um_user_role`
  ADD COLUMN `system` VARCHAR(8) NULL  AFTER `role_id`,
  ADD COLUMN `client` CHAR(3) NULL  AFTER `system`,
  ADD COLUMN `um_delete` TINYINT NOT NULL DEFAULT 0  AFTER `client`,
  ADD INDEX `sys_cli` (`system` ASC, `client` ASC),
  ADD INDEX `del` (`um_delete` ASC);

UPDATE um_user_role
  SET um_user_role.system=(SELECT um_role.system FROM um_role WHERE id=role_id), client=(SELECT client FROM um_role WHERE id=role_id);
