-- -----------------------------------------------------
-- Improved APM temp table handling
-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `temp_mgr` (
  `table` VARCHAR(64) NOT NULL,
  `guiid` CHAR(32) NOT NULL,
  `timestamp` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`table`, `guiid`),
  INDEX `ts` (`timestamp` ASC));


TRUNCATE TABLE temp_field;

ALTER TABLE `temp_field` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_object;

ALTER TABLE `temp_object` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_object_class;

ALTER TABLE `temp_object_class` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_orglvl;

ALTER TABLE `temp_orglvl` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_role;

ALTER TABLE `temp_role` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_role_tcode;

ALTER TABLE `temp_role_tcode` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_tcode;

ALTER TABLE `temp_tcode` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_user;

ALTER TABLE `temp_user` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_user_group;

ALTER TABLE `temp_user_group` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


TRUNCATE TABLE temp_user_role;

ALTER TABLE `temp_user_role` 
  DROP COLUMN `timestamp`,
  DROP INDEX `timestamp` ;


