SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES';


-- -----------------------------------------------------
-- Table searchResultT
-- -----------------------------------------------------
alter table searchResultT add relevancy double not null default 0.0;
alter table searchResultT add index relevancy_idx (sessionId asc, relevancy asc);

-- -----------------------------------------------------
-- Table searchResultSelectedT
-- -----------------------------------------------------
DROP TABLE IF EXISTS searchResultSelectedT ;

CREATE TABLE IF NOT EXISTS searchResultSelectedT (
  sessionId BIGINT UNSIGNED NOT NULL,
  objectId INT UNSIGNED NOT NULL,
  added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (sessionId, objectId),
  INDEX fk_searchResultSelectedT_objectT1_idx (objectId ASC),
  INDEX added_idx (sessionId ASC, added ASC),
  CONSTRAINT fk_searchResultSelectedT_searchSessionT1
    FOREIGN KEY (sessionId)
    REFERENCES searchSessionT (id)
    ON DELETE CASCADE
    ON UPDATE NO ACTION,
  CONSTRAINT fk_searchResultSelectedT_objectT1
    FOREIGN KEY (objectId)
    REFERENCES objectT (id)
    ON DELETE CASCADE
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
