
# -----------------------------------------------------------------------
# PORTLET_DEFINITION
# -----------------------------------------------------------------------
drop table if exists PORTLET_DEFINITION;

CREATE TABLE PORTLET_DEFINITION
(
    ID MEDIUMINT NOT NULL,
    NAME VARCHAR(80),
    CLASS_NAME VARCHAR(255),
    APPLICATION_ID MEDIUMINT NOT NULL,
    PORTLET_IDENTIFIER VARCHAR(80),
    EXPIRATION_CACHE VARCHAR(30),
    RESOURCE_BUNDLE VARCHAR(255),
    PREFERENCE_VALIDATOR VARCHAR(255),
    SECURITY_REF VARCHAR(40),
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# PORTLET_APPLICATION
# -----------------------------------------------------------------------
drop table if exists PORTLET_APPLICATION;

CREATE TABLE PORTLET_APPLICATION
(
    APPLICATION_ID MEDIUMINT NOT NULL,
    APP_NAME VARCHAR(80) NOT NULL,
    APP_IDENTIFIER VARCHAR(80),
    VERSION VARCHAR(80),
    APP_TYPE MEDIUMINT,
    CHECKSUM VARCHAR(80),
    DESCRIPTION VARCHAR(80),
    WEB_APP_ID MEDIUMINT NOT NULL,
    SECURITY_REF VARCHAR(40),
    PRIMARY KEY(APPLICATION_ID),
    UNIQUE (APP_NAME));

# -----------------------------------------------------------------------
# WEB_APPLICATION
# -----------------------------------------------------------------------
drop table if exists WEB_APPLICATION;

CREATE TABLE WEB_APPLICATION
(
    ID MEDIUMINT NOT NULL,
    CONTEXT_ROOT VARCHAR(255) NOT NULL,
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# PA_METADATA_FIELDS
# -----------------------------------------------------------------------
drop table if exists PA_METADATA_FIELDS;

CREATE TABLE PA_METADATA_FIELDS
(
    ID MEDIUMINT NOT NULL,
    OBJECT_ID MEDIUMINT NOT NULL,
    COLUMN_VALUE MEDIUMTEXT NOT NULL,
    NAME VARCHAR(100) NOT NULL,
    LOCALE_STRING VARCHAR(50) NOT NULL,
    PRIMARY KEY(ID),
    FOREIGN KEY (OBJECT_ID) REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
        ON DELETE CASCADE 
  );

# -----------------------------------------------------------------------
# PD_METADATA_FIELDS
# -----------------------------------------------------------------------
drop table if exists PD_METADATA_FIELDS;

CREATE TABLE PD_METADATA_FIELDS
(
    ID MEDIUMINT NOT NULL,
    OBJECT_ID MEDIUMINT NOT NULL,
    COLUMN_VALUE MEDIUMTEXT NOT NULL,
    NAME VARCHAR(100) NOT NULL,
    LOCALE_STRING VARCHAR(50) NOT NULL,
    PRIMARY KEY(ID),
    FOREIGN KEY (OBJECT_ID) REFERENCES PORTLET_DEFINITION (ID)
        ON DELETE CASCADE 
  );

# -----------------------------------------------------------------------
# LANGUAGE
# -----------------------------------------------------------------------
drop table if exists LANGUAGE;

CREATE TABLE LANGUAGE
(
    ID MEDIUMINT NOT NULL,
    PORTLET_ID MEDIUMINT NOT NULL,
    TITLE VARCHAR(100),
    SHORT_TITLE VARCHAR(100),
    LOCALE_STRING VARCHAR(50) NOT NULL,
    KEYWORDS MEDIUMTEXT,
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# PORTLET_CONTENT_TYPE
# -----------------------------------------------------------------------
drop table if exists PORTLET_CONTENT_TYPE;

CREATE TABLE PORTLET_CONTENT_TYPE
(
    CONTENT_TYPE_ID MEDIUMINT NOT NULL,
    PORTLET_ID MEDIUMINT NOT NULL,
    CONTENT_TYPE VARCHAR(30) NOT NULL,
    MODES MEDIUMTEXT,
    PRIMARY KEY(CONTENT_TYPE_ID));

# -----------------------------------------------------------------------
# PARAMETER
# -----------------------------------------------------------------------
drop table if exists PARAMETER;

CREATE TABLE PARAMETER
(
    PARAMETER_ID MEDIUMINT NOT NULL,
    PARENT_ID MEDIUMINT NOT NULL,
    CLASS_NAME VARCHAR(255) NOT NULL,
    NAME VARCHAR(80) NOT NULL,
    PARAMETER_VALUE MEDIUMTEXT NOT NULL,
    PRIMARY KEY(PARAMETER_ID));

# -----------------------------------------------------------------------
# PORTLET_ENTITY
# -----------------------------------------------------------------------
drop table if exists PORTLET_ENTITY;

CREATE TABLE PORTLET_ENTITY
(
    PEID MEDIUMINT NOT NULL,
    ID VARCHAR(255) NOT NULL,
    APP_NAME VARCHAR(255) NOT NULL,
    PORTLET_NAME VARCHAR(255) NOT NULL,
    PRIMARY KEY(PEID),
    UNIQUE (ID));

# -----------------------------------------------------------------------
# SECURITY_ROLE_REFERENCE
# -----------------------------------------------------------------------
drop table if exists SECURITY_ROLE_REFERENCE;

CREATE TABLE SECURITY_ROLE_REFERENCE
(
    ID MEDIUMINT NOT NULL,
    PORTLET_DEFINITION_ID MEDIUMINT NOT NULL,
    ROLE_NAME VARCHAR(150) NOT NULL,
    ROLE_LINK VARCHAR(150),
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# SECURITY_ROLE
# -----------------------------------------------------------------------
drop table if exists SECURITY_ROLE;

CREATE TABLE SECURITY_ROLE
(
    ID MEDIUMINT NOT NULL,
    WEB_APPLICATION_ID MEDIUMINT NOT NULL,
    ROLE_NAME VARCHAR(150) NOT NULL,
    DESCRIPTION VARCHAR(150),
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# USER_ATTRIBUTE_REF
# -----------------------------------------------------------------------
drop table if exists USER_ATTRIBUTE_REF;

CREATE TABLE USER_ATTRIBUTE_REF
(
    ID MEDIUMINT NOT NULL,
    APPLICATION_ID MEDIUMINT NOT NULL,
    NAME VARCHAR(150),
    NAME_LINK VARCHAR(150),
    PRIMARY KEY(ID),
    FOREIGN KEY (APPLICATION_ID) REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
        ON DELETE CASCADE 
  );

# -----------------------------------------------------------------------
# USER_ATTRIBUTE
# -----------------------------------------------------------------------
drop table if exists USER_ATTRIBUTE;

CREATE TABLE USER_ATTRIBUTE
(
    ID MEDIUMINT NOT NULL,
    APPLICATION_ID MEDIUMINT NOT NULL,
    NAME VARCHAR(150),
    DESCRIPTION VARCHAR(150),
    PRIMARY KEY(ID),
    FOREIGN KEY (APPLICATION_ID) REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
        ON DELETE CASCADE 
  );

# -----------------------------------------------------------------------
# JETSPEED_SERVICE
# -----------------------------------------------------------------------
drop table if exists JETSPEED_SERVICE;

CREATE TABLE JETSPEED_SERVICE
(
    ID MEDIUMINT NOT NULL,
    APPLICATION_ID MEDIUMINT NOT NULL,
    NAME VARCHAR(150),
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# LOCALIZED_DESCRIPTION
# -----------------------------------------------------------------------
drop table if exists LOCALIZED_DESCRIPTION;

CREATE TABLE LOCALIZED_DESCRIPTION
(
    ID MEDIUMINT NOT NULL,
    OBJECT_ID MEDIUMINT NOT NULL,
    CLASS_NAME VARCHAR(255) NOT NULL,
    DESCRIPTION MEDIUMTEXT NOT NULL,
    LOCALE_STRING VARCHAR(50) NOT NULL,
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# LOCALIZED_DISPLAY_NAME
# -----------------------------------------------------------------------
drop table if exists LOCALIZED_DISPLAY_NAME;

CREATE TABLE LOCALIZED_DISPLAY_NAME
(
    ID MEDIUMINT NOT NULL,
    OBJECT_ID MEDIUMINT NOT NULL,
    CLASS_NAME VARCHAR(255),
    DISPLAY_NAME MEDIUMTEXT NOT NULL,
    LOCALE_STRING VARCHAR(50) NOT NULL,
    PRIMARY KEY(ID));

# -----------------------------------------------------------------------
# CUSTOM_PORTLET_MODE
# -----------------------------------------------------------------------
drop table if exists CUSTOM_PORTLET_MODE;

CREATE TABLE CUSTOM_PORTLET_MODE
(
    ID MEDIUMINT NOT NULL,
    APPLICATION_ID MEDIUMINT NOT NULL,
    CUSTOM_NAME VARCHAR(150) NOT NULL,
    MAPPED_NAME VARCHAR(150),
    DESCRIPTION MEDIUMTEXT,
    PRIMARY KEY(ID),
    FOREIGN KEY (APPLICATION_ID) REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
        ON DELETE CASCADE 
  );

# -----------------------------------------------------------------------
# CUSTOM_WINDOW_STATE
# -----------------------------------------------------------------------
drop table if exists CUSTOM_WINDOW_STATE;

CREATE TABLE CUSTOM_WINDOW_STATE
(
    ID MEDIUMINT NOT NULL,
    APPLICATION_ID MEDIUMINT NOT NULL,
    CUSTOM_NAME VARCHAR(150) NOT NULL,
    MAPPED_NAME VARCHAR(150),
    DESCRIPTION MEDIUMTEXT,
    PRIMARY KEY(ID),
    FOREIGN KEY (APPLICATION_ID) REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
        ON DELETE CASCADE 
  );
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
