
--------------------------------------------------
-- 07/12/2019
-- Author: Tony Chen 
-- Following changes are made for data sharing with SeedMe2. 
--------------------------------------------------

DROP TABLE IF EXISTS tomcat_sessions; 

-- This table will be used by TomcatSessionManager. 
CREATE TABLE tomcat_sessions 
(
    id              BIGINT AUTO_INCREMENT,
    session_id      VARCHAR(100) NOT NULL,
    valid_session   CHAR(1) NOT NULL,
    max_inactive    INT NOT NULL,
    last_access     BIGINT NOT NULL,
    app_name        VARCHAR(255),
    session_data    MEDIUMBLOB, 
    user_id         BIGINT, 
    
    CONSTRAINT pk_tomcat_sessions_01 PRIMARY KEY (id), 
    CONSTRAINT uq_tomcat_sessions_01 UNIQUE (session_id), 

    CONSTRAINT fk_tomcat_sessions_01 FOREIGN KEY (user_id) REFERENCES users (USER_ID) 
        ON DELETE NO ACTION     ON UPDATE NO ACTION
);

CREATE INDEX ix_tomcat_sessions_01 ON tomcat_sessions (app_name);
