-- ------------------------------------------------
-- Optimize um_role_tcode
-- Created 20130617
-- ------------------------------------------------

ALTER TABLE `um_role_tcode`
  ADD COLUMN `system` VARCHAR(8) NULL  AFTER `delete_flag`,
  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_role_tcode
  SET um_role_tcode.system=(SELECT um_role.system FROM um_role WHERE id=role_id), client=(SELECT client FROM um_role WHERE id=role_id);
