Creating APPM datasources

application-manager-new
Chatura Dilan 8 years ago
parent cd26a8daec
commit 79325ac52a

@ -175,6 +175,34 @@
</configuration>
</execution>
<execution>
<!-- Creating App Management schema -->
<id>create-app-mgt-schema</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="########### Create App Management H2 Schema ###########" />
<property name="db.dir" value="target/wso2carbon-core-${carbon.kernel.version}/repository/database" />
<property name="userid" value="wso2carbon" />
<property name="password" value="wso2carbon" />
<property name="dbURL" value="jdbc:h2:file:${basedir}/${db.dir}/WSO2APPM_DB;DB_CLOSE_ON_EXIT=FALSE" />
<sql driver="org.h2.Driver" url="${dbURL}" userid="${userid}" password="${password}" autocommit="true" onerror="continue">
<classpath refid="maven.dependency.classpath" />
<classpath refid="maven.compile.classpath" />
<classpath refid="maven.runtime.classpath" />
<fileset file="${basedir}/src/repository/resources/dbscripts/appmgt/h2.sql" />
</sql>
<echo message="##################### END ####################" />
</tasks>
</configuration>
</execution>
<execution>
<!-- Creating JAGH2 schema -->
<id>create-JAGH2-schema</id>

@ -822,6 +822,15 @@
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<file>
<source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/application-authentication.xml
</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/identity
</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<!-- Copying thrift-authentication.xml -->
<file>
<source>src/repository/conf/application-authenticators.xml</source>
@ -842,12 +851,6 @@
</outputDirectory>
<fileMode>644</fileMode>
</file>
<file>
<source>src/repository/conf/identity/application-authentication.xml</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/identity
</outputDirectory>
<fileMode>644</fileMode>
</file>
<file>
<source>src/repository/conf/identity/thrift-authentication.xml</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/identity</outputDirectory>
@ -1033,6 +1036,15 @@
<destName>WSO2AM_DB.h2.db</destName>
<fileMode>644</fileMode>
</file>
<!-- Copying H2 database related files corresponding to default App management repository schema -->
<file>
<source>
target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2APPM_DB.h2.db
</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/database</outputDirectory>
<destName>WSO2APPM_DB.h2.db</destName>
<fileMode>644</fileMode>
</file>
<!-- Copying H2 database related files corresponding to default Device management repository schema -->
<file>
<source>

@ -6,7 +6,7 @@
JNDI name of the data source to be used by the app management components such as store, publisher, gateway
This data source should be defined in the master-datasources.xml file in conf/datasources directory.
-->
<DataSourceName>jdbc/WSO2AM_DB</DataSourceName>
<DataSourceName>jdbc/WSO2APPM_DB</DataSourceName>
<DataSources>
<Storage>jdbc/ES_Storage</Storage>
</DataSources>
@ -163,7 +163,7 @@
This data source is used to write/read UI Activity changes (eg: App Hit count)
to seperate database. When using DAS to analyze the changes it needs to configure this data source appropriately.
-->
<UIActivityPublishDataSourceName>jdbc/WSO2AM_DB</UIActivityPublishDataSourceName>
<UIActivityPublishDataSourceName>jdbc/WSO2APPM_DB</UIActivityPublishDataSourceName>
<!--
Enable UI Activity Data publish to DAS

@ -43,6 +43,27 @@
</definition>
</datasource>
<datasource>
<name>WSO2APPM_DB</name>
<description>The datasource used for App Manager database</description>
<jndiConfig>
<name>jdbc/WSO2APPM_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
<datasource>
<name>WSO2AM_DB</name>
<description>The datasource used for API Manager database</description>
@ -63,6 +84,7 @@
</configuration>
</definition>
</datasource>
<datasource>
<name>WSO2_MB_STORE_DB</name>
<description>The datasource used for message broker database</description>

@ -0,0 +1,61 @@
DELETE FROM AM_SUBSCRIPTION_KEY_MAPPING;
DELETE FROM AM_APPLICATION_KEY_MAPPING;
DELETE FROM AM_SUBSCRIPTION ;
DELETE FROM AM_APPLICATION ;
DELETE FROM AM_SUBSCRIBER;
DELETE FROM APPMGR_APP;
DELETE FROM IDN_OAUTH2_ACCESS_TOKEN ;
DELETE FROM IDN_OAUTH_CONSUMER_APPS;
ALTER TABLE AM_SUBSCRIBER ALTER COLUMN SUBSCRIBER_ID RESTART WITH 1;
ALTER TABLE AM_APPLICATION ALTER COLUMN APPLICATION_ID RESTART WITH 100;
ALTER TABLE APPMGR_APP ALTER COLUMN API_ID RESTART WITH 500;
ALTER TABLE AM_SUBSCRIPTION ALTER COLUMN SUBSCRIPTION_ID RESTART WITH 1000;
INSERT INTO AM_SUBSCRIBER ( USER_ID , TENANT_ID , EMAIL_ADDRESS , DATE_SUBSCRIBED ) VALUES ('SUMEDHA',-1234,'SUMEDHA@WSO2.COM','2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIBER ( USER_ID , TENANT_ID , EMAIL_ADDRESS , DATE_SUBSCRIBED ) VALUES ('PRABATH',-1234,'PRABATH@WSO2.COM','2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIBER ( USER_ID , TENANT_ID , EMAIL_ADDRESS , DATE_SUBSCRIBED ) VALUES ('THILINA',-1234,'THILINA@WSO2.COM','2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIBER ( USER_ID , TENANT_ID , EMAIL_ADDRESS , DATE_SUBSCRIBED ) VALUES ('UDAYANGA',-1234,'UDAYANGA@WSO2.COM','2012-03-05 12:10:11');
INSERT INTO AM_APPLICATION (NAME,SUBSCRIBER_ID ) VALUES ('APPLICATION1',1);
INSERT INTO AM_APPLICATION (NAME,SUBSCRIBER_ID ) VALUES ('APPLICATION2',1);
INSERT INTO AM_APPLICATION (NAME,SUBSCRIBER_ID ) VALUES ('APPLICATION3',2);
INSERT INTO AM_APPLICATION (NAME,SUBSCRIBER_ID ) VALUES ('APPLICATION4',2);
INSERT INTO AM_APPLICATION (NAME,SUBSCRIBER_ID ) VALUES ('APPLICATION5',3);
INSERT INTO AM_APPLICATION (NAME,SUBSCRIBER_ID ) VALUES ('DeliciousApp',4);
INSERT INTO APPMGR_APP (API_PROVIDER,API_NAME,API_VERSION,CONTEXT) VALUES ('SUMEDHA', 'API1', 'V1.0.0','/context1');
INSERT INTO APPMGR_APP (API_PROVIDER,API_NAME,API_VERSION,CONTEXT) VALUES ('PRABATH', 'API2', 'V1.0.0','/deli2');
INSERT INTO APPMGR_APP (API_PROVIDER,API_NAME,API_VERSION,CONTEXT) VALUES ('ADMIN', 'API3', 'V1.0.0','/test');
INSERT INTO APPMGR_APP (API_PROVIDER,API_NAME,API_VERSION,CONTEXT) VALUES ('DEL', 'Delicious', '1.0.0','/deli');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',500,100,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',501,101,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',500,102,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',502,103,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',501,104,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',503,105,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION ( TIER_ID , API_ID , APPLICATION_ID , LAST_ACCESSED ) VALUES ('T1',501,102,'2012-03-05 12:10:11');
INSERT INTO AM_SUBSCRIPTION_KEY_MAPPING (SUBSCRIPTION_ID, ACCESS_TOKEN, KEY_TYPE) VALUES (1000, 'SSDCHEJJ-AWUIS-232', 'PRODUCTION');
INSERT INTO AM_SUBSCRIPTION_KEY_MAPPING (SUBSCRIPTION_ID, ACCESS_TOKEN, KEY_TYPE) VALUES (1001, 'a1b2c3d4', 'SANDBOX');
INSERT INTO AM_SUBSCRIPTION_KEY_MAPPING (SUBSCRIPTION_ID, ACCESS_TOKEN, KEY_TYPE) VALUES (1002, 'p1q2r3s4', 'PRODUCTION');
INSERT INTO AM_APPLICATION_KEY_MAPPING (APPLICATION_ID, CONSUMER_KEY, KEY_TYPE) VALUES (100, 'CON1', 'PRODUCTION');
INSERT INTO AM_APPLICATION_KEY_MAPPING (APPLICATION_ID, CONSUMER_KEY, KEY_TYPE) VALUES (100, 'CON2', 'SANDBOX');
INSERT INTO AM_APPLICATION_KEY_MAPPING (APPLICATION_ID, CONSUMER_KEY, KEY_TYPE) VALUES (101, 'CON3', 'PRODUCTION');
INSERT INTO IDN_OAUTH_CONSUMER_APPS ( APP_NAME , CALLBACK_URL , CONSUMER_KEY , CONSUMER_SECRET ,OAUTH_VERSION , TENANT_ID , USERNAME ) VALUES (NULL,NULL,'CON1','MY PEN','2.0',0,'PRABATH');
INSERT INTO IDN_OAUTH_CONSUMER_APPS ( APP_NAME , CALLBACK_URL , CONSUMER_KEY , CONSUMER_SECRET ,OAUTH_VERSION , TENANT_ID , USERNAME ) VALUES (NULL,NULL,'CON2','MY PEN','2.0',0,'PRABATH');
INSERT INTO IDN_OAUTH_CONSUMER_APPS ( APP_NAME , CALLBACK_URL , CONSUMER_KEY , CONSUMER_SECRET ,OAUTH_VERSION , TENANT_ID , USERNAME ) VALUES (NULL,NULL,'CON3','MY PEN','2.0',0,'admin');
INSERT INTO IDN_OAUTH2_ACCESS_TOKEN ( ACCESS_TOKEN ,AUTHZ_USER , USER_TYPE , CONSUMER_KEY , REFRESH_TOKEN ,TIME_CREATED , TOKEN_SCOPE , TOKEN_STATE ,VALIDITY_PERIOD ) VALUES ('a1b2c3d4','UDAYANGA','DEVELOPER','CON1',NULL,'2012-01-01','SANDBOX','ACTIVE',1343714931875);
INSERT INTO IDN_OAUTH2_ACCESS_TOKEN ( ACCESS_TOKEN ,AUTHZ_USER , USER_TYPE , CONSUMER_KEY , REFRESH_TOKEN ,TIME_CREATED , TOKEN_SCOPE , TOKEN_STATE ,VALIDITY_PERIOD ) VALUES ('p1q2r3s4','UDAYANGA','DEVELOPER','CON1',NULL,'2012-01-01','PRODUCTION','ACTIVE',1343714931875);
INSERT INTO IDN_OAUTH2_ACCESS_TOKEN ( ACCESS_TOKEN ,AUTHZ_USER , USER_TYPE , CONSUMER_KEY , REFRESH_TOKEN ,TIME_CREATED , TOKEN_SCOPE , TOKEN_STATE ,VALIDITY_PERIOD ) VALUES ('test1','UDAYANGA','DEVELOPER','CON1',NULL,'2012-01-01','PRODUCTION','ACTIVE',1343714931875);
INSERT INTO IDN_OAUTH2_ACCESS_TOKEN ( ACCESS_TOKEN ,AUTHZ_USER , USER_TYPE , CONSUMER_KEY , REFRESH_TOKEN ,TIME_CREATED , TOKEN_SCOPE , TOKEN_STATE ,VALIDITY_PERIOD ) VALUES ('test2','UDAYANGA','DEVELOPER','CON2',NULL,'2012-01-01','SANDBOX','ACTIVE',1343714931875);
INSERT INTO IDN_OAUTH2_ACCESS_TOKEN ( ACCESS_TOKEN ,AUTHZ_USER , USER_TYPE , CONSUMER_KEY , REFRESH_TOKEN ,TIME_CREATED , TOKEN_SCOPE , TOKEN_STATE ,VALIDITY_PERIOD ) VALUES ('test3','UDAYANGA','DEVELOPER','CON3',NULL,'2012-01-01','PRODUCTION','ACTIVE',3600);
SELECT * FROM AM_SUBSCRIBER;
SELECT * FROM AM_APPLICATION;
SELECT * FROM AM_SUBSCRIPTION;

@ -0,0 +1,304 @@
CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS (
ID INTEGER NOT NULL AUTO_INCREMENT,
CONSUMER_KEY VARCHAR (255),
CONSUMER_SECRET VARCHAR (512),
USERNAME VARCHAR (255),
TENANT_ID INTEGER DEFAULT 0,
USER_DOMAIN VARCHAR(50),
APP_NAME VARCHAR (255),
OAUTH_VERSION VARCHAR (128),
CALLBACK_URL VARCHAR (1024),
GRANT_TYPES VARCHAR (1024),
CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY),
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS APM_SUBSCRIBER (
SUBSCRIBER_ID INTEGER AUTO_INCREMENT,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EMAIL_ADDRESS VARCHAR(256) NULL,
DATE_SUBSCRIBED TIMESTAMP NOT NULL,
PRIMARY KEY (SUBSCRIBER_ID),
UNIQUE (TENANT_ID,USER_ID)
);
CREATE TABLE IF NOT EXISTS APM_APPLICATION (
APPLICATION_ID INTEGER AUTO_INCREMENT,
NAME VARCHAR(100),
SUBSCRIBER_ID INTEGER,
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES APM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
);
CREATE TABLE IF NOT EXISTS APM_BUSINESS_OWNER(
OWNER_ID INTEGER AUTO_INCREMENT,
OWNER_NAME VARCHAR(200) NOT NULL,
OWNER_EMAIL VARCHAR(300) NOT NULL,
OWNER_DESC VARCHAR(1500),
OWNER_SITE VARCHAR(200),
TENANT_ID INTEGER,
PRIMARY KEY(OWNER_ID),
UNIQUE (OWNER_NAME,OWNER_EMAIL,TENANT_ID)
);
CREATE TABLE IF NOT EXISTS APM_BUSINESS_OWNER_PROPERTY(
OWNER_PROP_ID INTEGER AUTO_INCREMENT,
OWNER_ID INTEGER NOT NULL,
NAME VARCHAR(200) NOT NULL,
VALUE VARCHAR(300) NOT NULL,
SHOW_IN_STORE BOOLEAN NOT NULL,
PRIMARY KEY(OWNER_PROP_ID),
FOREIGN KEY(OWNER_ID) REFERENCES APM_BUSINESS_OWNER(OWNER_ID)
);
CREATE TABLE IF NOT EXISTS APM_APP (
APP_ID INTEGER AUTO_INCREMENT,
APP_PROVIDER VARCHAR(256),
TENANT_ID INTEGER,
APP_NAME VARCHAR(256),
APP_VERSION VARCHAR(30),
CONTEXT VARCHAR(256),
TRACKING_CODE varchar(100),
VISIBLE_ROLES varchar(500),
UUID varchar(500),
SAML2_SSO_ISSUER varchar(500),
LOG_OUT_URL varchar(500),
APP_ALLOW_ANONYMOUS BOOLEAN NULL,
APP_ENDPOINT varchar(500),
TREAT_AS_SITE BOOLEAN NOT NULL,
PRIMARY KEY(APP_ID),
UNIQUE (APP_PROVIDER,APP_NAME,APP_VERSION,TRACKING_CODE,UUID)
);
CREATE TABLE IF NOT EXISTS APM_POLICY_GROUP
(
POLICY_GRP_ID INTEGER AUTO_INCREMENT,
NAME VARCHAR(256),
AUTH_SCHEME VARCHAR(50) NULL,
THROTTLING_TIER varchar(512) DEFAULT NULL,
USER_ROLES varchar(512) DEFAULT NULL,
URL_ALLOW_ANONYMOUS BOOLEAN DEFAULT FALSE,
DESCRIPTION VARCHAR(1000) NULL,
PRIMARY KEY (POLICY_GRP_ID)
);
CREATE TABLE IF NOT EXISTS APM_POLICY_GROUP_MAPPING
(
POLICY_GRP_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (POLICY_GRP_ID,APP_ID)
);
CREATE TABLE IF NOT EXISTS APM_APP_URL_MAPPING (
URL_MAPPING_ID INTEGER AUTO_INCREMENT,
APP_ID INTEGER NOT NULL,
HTTP_METHOD VARCHAR(20) NULL,
URL_PATTERN VARCHAR(512) NULL,
SKIP_THROTTLING BOOLEAN DEFAULT FALSE,
POLICY_GRP_ID INTEGER NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID),
PRIMARY KEY(URL_MAPPING_ID)
);
CREATE TABLE IF NOT EXISTS APM_ENTITLEMENT_POLICY_PARTIAL (
ENTITLEMENT_POLICY_PARTIAL_ID INTEGER AUTO_INCREMENT,
NAME varchar(256) DEFAULT NULL,
CONTENT varchar(2048) DEFAULT NULL,
SHARED BOOLEAN DEFAULT FALSE,
AUTHOR varchar(256) DEFAULT NULL,
DESCRIPTION VARCHAR(1000) NULL,
TENANT_ID INTEGER NULL,
PRIMARY KEY(ENTITLEMENT_POLICY_PARTIAL_ID)
);
CREATE TABLE IF NOT EXISTS APM_POLICY_GRP_PARTIAL_MAPPING (
POLICY_GRP_ID INTEGER NOT NULL,
POLICY_PARTIAL_ID INTEGER NOT NULL,
EFFECT varchar(50),
POLICY_ID varchar(100) DEFAULT NULL,
FOREIGN KEY(POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP(POLICY_GRP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY(POLICY_PARTIAL_ID) REFERENCES APM_ENTITLEMENT_POLICY_PARTIAL(ENTITLEMENT_POLICY_PARTIAL_ID),
PRIMARY KEY(POLICY_GRP_ID, POLICY_PARTIAL_ID)
);
CREATE TABLE IF NOT EXISTS APM_SUBSCRIPTION (
SUBSCRIPTION_ID INTEGER AUTO_INCREMENT,
SUBSCRIPTION_TYPE VARCHAR(50),
TIER_ID VARCHAR(50),
APP_ID INTEGER,
LAST_ACCESSED TIMESTAMP NULL,
APPLICATION_ID INTEGER,
SUB_STATUS VARCHAR(50),
TRUSTED_IDP VARCHAR(255) NULL,
SUBSCRIPTION_TIME TIMESTAMP NOT NULL,
FOREIGN KEY(APPLICATION_ID) REFERENCES APM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (SUBSCRIPTION_ID),
UNIQUE(APP_ID, APPLICATION_ID,SUBSCRIPTION_TYPE)
);
CREATE TABLE IF NOT EXISTS APM_APP_LC_EVENT (
EVENT_ID INTEGER AUTO_INCREMENT,
APP_ID INTEGER NOT NULL,
PREVIOUS_STATE VARCHAR(50),
NEW_STATE VARCHAR(50) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EVENT_DATE TIMESTAMP NOT NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (EVENT_ID)
);
CREATE TABLE IF NOT EXISTS APM_TIER_PERMISSIONS (
TIER_PERMISSIONS_ID INTEGER AUTO_INCREMENT,
TIER VARCHAR(50) NOT NULL,
PERMISSIONS_TYPE VARCHAR(50) NOT NULL,
ROLES VARCHAR(512) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(TIER_PERMISSIONS_ID)
);
CREATE TABLE IF NOT EXISTS APM_WORKFLOWS(
WF_ID INTEGER AUTO_INCREMENT,
WF_REFERENCE VARCHAR(255) NOT NULL,
WF_TYPE VARCHAR(255) NOT NULL,
WF_STATUS VARCHAR(255) NOT NULL,
WF_CREATED_TIME TIMESTAMP,
WF_UPDATED_TIME TIMESTAMP,
WF_STATUS_DESC VARCHAR(1000),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL,
PRIMARY KEY (WF_ID),
UNIQUE (WF_EXTERNAL_REFERENCE)
);
CREATE TABLE IF NOT EXISTS APM_API_CONSUMER_APPS (
ID INTEGER AUTO_INCREMENT,
SAML2_SSO_ISSUER varchar(500),
APP_CONSUMER_KEY VARCHAR(512),
API_TOKEN_ENDPOINT VARCHAR (1024),
API_CONSUMER_KEY VARCHAR(512),
API_CONSUMER_SECRET VARCHAR(512),
APP_NAME VARCHAR(512),
PRIMARY KEY (ID, APP_CONSUMER_KEY),
FOREIGN KEY (SAML2_SSO_ISSUER) REFERENCES APM_APP(SAML2_SSO_ISSUER),
FOREIGN KEY (APP_CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS APM_APP_HITS (
UUID VARCHAR(500) NOT NULL,
APP_NAME VARCHAR(200) NOT NULL,
VERSION VARCHAR(50),
CONTEXT VARCHAR(256) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER,
HIT_TIME TIMESTAMP NOT NULL,
PRIMARY KEY (UUID, USER_ID, TENANT_ID, HIT_TIME)
);
CREATE TABLE IF NOT EXISTS APM_APP_JAVA_POLICY
(
JAVA_POLICY_ID INTEGER AUTO_INCREMENT,
DISPLAY_NAME VARCHAR(100) NOT NULL,
FULL_QUALIFI_NAME VARCHAR(256) NOT NULL,
DESCRIPTION VARCHAR(2500),
DISPLAY_ORDER_SEQ_NO INTEGER NOT NULL,
IS_MANDATORY BOOLEAN DEFAULT FALSE,
POLICY_PROPERTIES VARCHAR(512) NULL,
IS_GLOBAL BOOLEAN DEFAULT TRUE,
PRIMARY KEY(JAVA_POLICY_ID),
UNIQUE(FULL_QUALIFI_NAME,DISPLAY_ORDER_SEQ_NO)
);
CREATE TABLE IF NOT EXISTS APM_APP_JAVA_POLICY_MAPPING
(
JAVA_POLICY_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
PRIMARY KEY (JAVA_POLICY_ID,APP_ID),
FOREIGN KEY (JAVA_POLICY_ID) REFERENCES APM_APP_JAVA_POLICY(JAVA_POLICY_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS APM_EXTERNAL_STORES(
APP_STORE_ID INTEGER AUTO_INCREMENT,
APP_ID INTEGER,
STORE_ID VARCHAR(255) NOT NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (APP_STORE_ID)
);
CREATE TABLE IF NOT EXISTS APM_APP_DEFAULT_VERSION(
DEFAULT_VERSION_ID INTEGER AUTO_INCREMENT,
APP_NAME VARCHAR(256),
APP_PROVIDER VARCHAR(256),
DEFAULT_APP_VERSION VARCHAR(30),
PUBLISHED_DEFAULT_APP_VERSION VARCHAR(30),
TENANT_ID INTEGER,
PRIMARY KEY(DEFAULT_VERSION_ID)
);
CREATE TABLE IF NOT EXISTS APM_FAVOURITE_APPS (
ID INTEGER AUTO_INCREMENT,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
CREATED_TIME TIMESTAMP NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
UNIQUE (TENANT_ID,USER_ID,APP_ID)
);
CREATE TABLE IF NOT EXISTS APM_STORE_FAVOURITE_PAGE (
ID INTEGER AUTO_INCREMENT,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID_OF_USER INTEGER NOT NULL,
TENANT_ID_OF_STORE INTEGER NOT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS APM_ONE_TIME_DOWNLOAD_LINK(
ID INTEGER AUTO_INCREMENT,
BINARY_FILE varchar(500) NOT NULL,
UUID varchar(500) NOT NULL,
IS_DOWNLOADED BOOLEAN NOT NULL,
USERNAME VARCHAR(255),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID)
);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY, IS_GLOBAL )
VALUES ('Reverse Proxy Handler','org.wso2.carbon.appmgt.gateway.handlers.proxy.ReverseProxyHandler','',1,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('SAML2 Authentication Handler','org.wso2.carbon.appmgt.gateway.handlers.security.authentication.SAML2AuthenticationHandler','',2,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Subscription Handler', 'org.wso2.carbon.appmgt.gateway.handlers.subscription.SubscriptionsHandler', '', 3,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Authorization Handler', 'org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.AuthorizationHandler','',4,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Entitlement Handler','org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.EntitlementHandler','',5,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY, POLICY_PROPERTIES,IS_GLOBAL )
VALUES ('API Throttle Handler','org.wso2.carbon.appmgt.gateway.handlers.throttling.APIThrottleHandler','',6,TRUE,'{ "id": "A", "policyKey": "gov:/appmgt/applicationdata/tiers.xml"}',TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Publish Statistics:','org.wso2.carbon.appmgt.usage.publisher.APPMgtUsageHandler','',7,FALSE,TRUE);
CREATE INDEX IDX_SUB_APP_ID ON APM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID);

@ -0,0 +1,394 @@
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[IDN_OAUTH_CONSUMER_APPS]') AND TYPE IN (N'U'))
CREATE TABLE IDN_OAUTH_CONSUMER_APPS (
ID INTEGER IDENTITY,
CONSUMER_KEY VARCHAR(512),
CONSUMER_SECRET VARCHAR(512),
USERNAME VARCHAR(255),
TENANT_ID INTEGER DEFAULT 0,
USER_DOMAIN VARCHAR(50),
APP_NAME VARCHAR(255),
OAUTH_VERSION VARCHAR(128),
CALLBACK_URL VARCHAR(1024),
GRANT_TYPES VARCHAR(1024),
PRIMARY KEY (ID),
UNIQUE (CONSUMER_KEY)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_SUBSCRIBER]') AND TYPE IN (N'U'))
CREATE TABLE APM_SUBSCRIBER (
SUBSCRIBER_ID INTEGER IDENTITY,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EMAIL_ADDRESS VARCHAR(256) NULL,
DATE_SUBSCRIBED DATETIME2(0) NOT NULL,
PRIMARY KEY (SUBSCRIBER_ID),
UNIQUE (TENANT_ID, USER_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APPLICATION]') AND TYPE IN (N'U'))
CREATE TABLE APM_APPLICATION (
APPLICATION_ID INTEGER IDENTITY,
NAME VARCHAR(100),
SUBSCRIBER_ID INTEGER,
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
FOREIGN KEY (SUBSCRIBER_ID) REFERENCES APM_SUBSCRIBER (SUBSCRIBER_ID) ON UPDATE CASCADE,
PRIMARY KEY (APPLICATION_ID),
UNIQUE ( NAME, SUBSCRIBER_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_BUSINESS_OWNER') AND TYPE IN (N'U'))
CREATE TABLE APM_BUSINESS_OWNER(
OWNER_ID INTEGER IDENTITY,
OWNER_NAME VARCHAR(200) NOT NULL,
OWNER_EMAIL VARCHAR(300) NOT NULL,
OWNER_DESC VARCHAR(1500),
OWNER_SITE VARCHAR(200),
TENANT_ID INTEGER,
PRIMARY KEY(OWNER_ID),
UNIQUE (OWNER_NAME,OWNER_EMAIL,TENANT_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_BUSINESS_OWNER_PROPERTY') AND TYPE IN (N'U'))
CREATE TABLE APM_BUSINESS_OWNER_PROPERTY(
OWNER_PROP_ID INTEGER IDENTITY,
OWNER_ID INTEGER NOT NULL,
NAME VARCHAR(200) NOT NULL,
VALUE VARCHAR(300) NOT NULL,
SHOW_IN_STORE BIT NOT NULL,
PRIMARY KEY(OWNER_PROP_ID),
FOREIGN KEY(OWNER_ID) REFERENCES APM_BUSINESS_OWNER(OWNER_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP (
APP_ID INTEGER IDENTITY,
APP_PROVIDER VARCHAR(256),
TENANT_ID INTEGER,
APP_NAME VARCHAR(256),
APP_VERSION VARCHAR(30),
CONTEXT VARCHAR(256),
TRACKING_CODE VARCHAR(100),
VISIBLE_ROLES VARCHAR(500),
UUID VARCHAR(500) NOT NULL,
SAML2_SSO_ISSUER VARCHAR(500),
LOG_OUT_URL VARCHAR(500),
APP_ALLOW_ANONYMOUS BIT NULL,
APP_ENDPOINT VARCHAR(500),
TREAT_AS_SITE BIT NOT NULL,
PRIMARY KEY (APP_ID),
UNIQUE (APP_PROVIDER, APP_NAME, APP_VERSION, TRACKING_CODE, UUID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_POLICY_GROUP]') AND TYPE IN (N'U'))
CREATE TABLE APM_POLICY_GROUP
(
POLICY_GRP_ID INTEGER IDENTITY,
NAME VARCHAR(256),
AUTH_SCHEME VARCHAR(50) NULL,
THROTTLING_TIER VARCHAR(512) DEFAULT NULL,
USER_ROLES VARCHAR(512) DEFAULT NULL,
URL_ALLOW_ANONYMOUS BIT DEFAULT 0,
DESCRIPTION VARCHAR(1000) NULL,
PRIMARY KEY (POLICY_GRP_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_POLICY_GROUP_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE APM_POLICY_GROUP_MAPPING
(
POLICY_GRP_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP (APP_ID)
ON UPDATE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID)
ON UPDATE CASCADE,
PRIMARY KEY (POLICY_GRP_ID, APP_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP_URL_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP_URL_MAPPING (
URL_MAPPING_ID INTEGER IDENTITY,
APP_ID INTEGER NOT NULL,
HTTP_METHOD VARCHAR(20) NULL,
URL_PATTERN VARCHAR(512) NULL,
SKIP_THROTTLING BIT DEFAULT 0,
POLICY_GRP_ID INTEGER NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP (APP_ID)
ON UPDATE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID),
PRIMARY KEY (URL_MAPPING_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_ENTITLEMENT_POLICY_PARTIAL]') AND TYPE IN (N'U'))
CREATE TABLE APM_ENTITLEMENT_POLICY_PARTIAL (
ENTITLEMENT_POLICY_PARTIAL_ID INTEGER IDENTITY,
NAME VARCHAR(256) DEFAULT NULL,
CONTENT VARCHAR(2048) DEFAULT NULL,
SHARED BIT DEFAULT 0,
AUTHOR VARCHAR(256) DEFAULT NULL,
DESCRIPTION VARCHAR(1000) NULL,
TENANT_ID INTEGER NULL,
PRIMARY KEY (ENTITLEMENT_POLICY_PARTIAL_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_POLICY_GRP_PARTIAL_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE APM_POLICY_GRP_PARTIAL_MAPPING (
POLICY_GRP_ID INTEGER NOT NULL,
POLICY_PARTIAL_ID INTEGER NOT NULL,
EFFECT VARCHAR(50),
POLICY_ID VARCHAR(100) DEFAULT NULL,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID)
ON UPDATE CASCADE,
FOREIGN KEY (POLICY_PARTIAL_ID) REFERENCES APM_ENTITLEMENT_POLICY_PARTIAL (ENTITLEMENT_POLICY_PARTIAL_ID),
PRIMARY KEY (POLICY_GRP_ID, POLICY_PARTIAL_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_SUBSCRIPTION]') AND TYPE IN (N'U'))
CREATE TABLE APM_SUBSCRIPTION (
SUBSCRIPTION_ID INTEGER IDENTITY,
SUBSCRIPTION_TYPE VARCHAR(50),
TIER_ID VARCHAR(50),
APP_ID INTEGER,
LAST_ACCESSED DATETIME2(0) NULL,
APPLICATION_ID INTEGER,
SUB_STATUS VARCHAR(50),
TRUSTED_IDP VARCHAR(255) NULL,
SUBSCRIPTION_TIME DATETIME2(0) NOT NULL,
FOREIGN KEY (APPLICATION_ID) REFERENCES APM_APPLICATION (APPLICATION_ID)
ON UPDATE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE,
PRIMARY KEY (SUBSCRIPTION_ID),
UNIQUE (APP_ID, APPLICATION_ID, SUBSCRIPTION_TYPE)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP_LC_EVENT]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP_LC_EVENT (
EVENT_ID INTEGER IDENTITY,
APP_ID INTEGER NOT NULL,
PREVIOUS_STATE VARCHAR(50),
NEW_STATE VARCHAR(50) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EVENT_DATE DATETIME2(0) NOT NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP (APP_ID)
ON UPDATE CASCADE,
PRIMARY KEY (EVENT_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_TIER_PERMISSIONS]') AND TYPE IN (N'U'))
CREATE TABLE APM_TIER_PERMISSIONS (
TIER_PERMISSIONS_ID INTEGER IDENTITY,
TIER VARCHAR(50) NOT NULL,
PERMISSIONS_TYPE VARCHAR(50) NOT NULL,
ROLES VARCHAR(512) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (TIER_PERMISSIONS_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_WORKFLOWS]') AND TYPE IN (N'U'))
CREATE TABLE APM_WORKFLOWS (
WF_ID INTEGER IDENTITY,
WF_REFERENCE VARCHAR(255) NOT NULL,
WF_TYPE VARCHAR(255) NOT NULL,
WF_STATUS VARCHAR(255) NOT NULL,
WF_CREATED_TIME DATETIME2(0),
WF_UPDATED_TIME DATETIME2(0),
WF_STATUS_DESC VARCHAR(1000),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL,
PRIMARY KEY (WF_ID),
UNIQUE (WF_EXTERNAL_REFERENCE)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_API_CONSUMER_APPS]') AND TYPE IN (N'U'))
CREATE TABLE APM_API_CONSUMER_APPS (
ID INTEGER IDENTITY,
SAML2_SSO_ISSUER VARCHAR(500),
APP_CONSUMER_KEY VARCHAR(512),
API_TOKEN_ENDPOINT VARCHAR(1024),
API_CONSUMER_KEY VARCHAR(512),
API_CONSUMER_SECRET VARCHAR(512),
APP_NAME VARCHAR(512),
PRIMARY KEY (ID, APP_CONSUMER_KEY),
FOREIGN KEY (APP_CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS (CONSUMER_KEY)
ON UPDATE CASCADE);
IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name = 'IDX_APM_APP_UUID' AND object_id = OBJECT_ID('APM_APP'))
CREATE INDEX IDX_APM_APP_UUID ON APM_APP (UUID);
IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name = 'IDX_APM_SUBSCRIBER_USER_ID' AND object_id = OBJECT_ID('APM_SUBSCRIBER'))
CREATE INDEX IDX_APM_SUBSCRIBER_USER_ID ON APM_SUBSCRIBER (USER_ID);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP_HITS]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP_HITS (
UUID VARCHAR(500) NOT NULL,
APP_NAME VARCHAR(200) NOT NULL,
VERSION VARCHAR(50),
CONTEXT VARCHAR(256) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER,
HIT_TIME DATETIME2(0) NOT NULL,
PRIMARY KEY (UUID, USER_ID, TENANT_ID, HIT_TIME)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP_JAVA_POLICY]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP_JAVA_POLICY
(
JAVA_POLICY_ID INTEGER IDENTITY,
DISPLAY_NAME VARCHAR(100) NOT NULL,
FULL_QUALIFI_NAME VARCHAR(256) NOT NULL,
DESCRIPTION VARCHAR(2500),
DISPLAY_ORDER_SEQ_NO INTEGER NOT NULL,
IS_MANDATORY BIT DEFAULT 0,
POLICY_PROPERTIES VARCHAR(512) NULL,
IS_GLOBAL BIT DEFAULT 1,
PRIMARY KEY (JAVA_POLICY_ID),
UNIQUE (FULL_QUALIFI_NAME, DISPLAY_ORDER_SEQ_NO)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP_JAVA_POLICY_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP_JAVA_POLICY_MAPPING
(
JAVA_POLICY_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
PRIMARY KEY (JAVA_POLICY_ID, APP_ID),
FOREIGN KEY (JAVA_POLICY_ID) REFERENCES APM_APP_JAVA_POLICY (JAVA_POLICY_ID)
ON UPDATE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES APM_APP (APP_ID)
ON UPDATE CASCADE
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_EXTERNAL_STORES]') AND TYPE IN (N'U'))
CREATE TABLE APM_EXTERNAL_STORES (
APP_STORE_ID INTEGER IDENTITY,
APP_ID INTEGER,
STORE_ID VARCHAR(255) NOT NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP (APP_ID)
ON UPDATE CASCADE,
PRIMARY KEY (APP_STORE_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_APP_DEFAULT_VERSION]') AND TYPE IN (N'U'))
CREATE TABLE APM_APP_DEFAULT_VERSION(
DEFAULT_VERSION_ID INTEGER IDENTITY,
APP_NAME VARCHAR(256),
APP_PROVIDER VARCHAR(256),
DEFAULT_APP_VERSION VARCHAR(30),
PUBLISHED_DEFAULT_APP_VERSION VARCHAR(30),
TENANT_ID INTEGER,
PRIMARY KEY(DEFAULT_VERSION_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_FAVOURITE_APPS]') AND TYPE IN (N'U'))
CREATE TABLE APM_FAVOURITE_APPS (
ID INTEGER IDENTITY,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
CREATED_TIME DATETIME2(0) NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
UNIQUE (TENANT_ID,USER_ID,APP_ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_STORE_FAVOURITE_PAGE]') AND TYPE IN (N'U'))
CREATE TABLE APM_STORE_FAVOURITE_PAGE (
ID INTEGER IDENTITY,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID_OF_USER INTEGER NOT NULL,
TENANT_ID_OF_STORE INTEGER NOT NULL,
PRIMARY KEY (ID)
);
IF NOT EXISTS(SELECT *
FROM SYS.OBJECTS
WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APM_ONE_TIME_DOWNLOAD_LINK]') AND TYPE IN (N'U'))
CREATE TABLE APM_ONE_TIME_DOWNLOAD_LINK(
ID INTEGER IDENTITY,
BINARY_FILE varchar(500) NOT NULL,
UUID varchar(500) NOT NULL,
IS_DOWNLOADED BIT DEFAULT 0,
USERNAME VARCHAR(255),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
CREATED_TIME DATETIME2(0) NOT NULL,
PRIMARY KEY (ID)
);
INSERT INTO APM_APP_JAVA_POLICY (DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO, IS_MANDATORY, IS_GLOBAL)
VALUES
('Reverse Proxy Handler', 'org.wso2.carbon.appmgt.gateway.handlers.proxy.ReverseProxyHandler', '', 1, 1, 1);
INSERT INTO APM_APP_JAVA_POLICY (DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO, IS_MANDATORY, IS_GLOBAL)
VALUES
('SAML2 Authentication Handler', 'org.wso2.carbon.appmgt.gateway.handlers.security.saml2.SAML2AuthenticationHandler',
'', 2, 1, 1);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Subscription Handler', 'org.wso2.carbon.appmgt.gateway.handlers.subscription.SubscriptionsHandler', '', 3,1,1);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Authorization Handler', 'org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.AuthorizationHandler','',4,1,1);
INSERT INTO APM_APP_JAVA_POLICY (DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO, IS_MANDATORY, IS_GLOBAL)
VALUES ('Entitlement Handler', 'org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.EntitlementHandler', '', 3,
1, 1);
INSERT INTO APM_APP_JAVA_POLICY (DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO, IS_MANDATORY, POLICY_PROPERTIES, IS_GLOBAL)
VALUES ('API Throttle Handler', 'org.wso2.carbon.appmgt.gateway.handlers.throttling.APIThrottleHandler', '', 4, 1,
'{ "id": "A", "policyKey": "gov:/appmgt/applicationdata/tiers.xml"}', 1);
INSERT INTO APM_APP_JAVA_POLICY (DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO, IS_MANDATORY, IS_GLOBAL)
VALUES ('Publish Statistics:', 'org.wso2.carbon.appmgt.usage.publisher.APPMgtUsageHandler', '', 5, 0, 1);
CREATE INDEX IDX_SUB_APP_ID ON APM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID);

@ -0,0 +1,307 @@
CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS (
ID INTEGER NOT NULL AUTO_INCREMENT,
CONSUMER_KEY VARCHAR(255),
CONSUMER_SECRET VARCHAR(512),
USERNAME VARCHAR(255),
TENANT_ID INTEGER DEFAULT 0,
USER_DOMAIN VARCHAR(50),
APP_NAME VARCHAR(255),
OAUTH_VERSION VARCHAR(128),
CALLBACK_URL VARCHAR(1024),
GRANT_TYPES VARCHAR (1024),
CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY),
PRIMARY KEY (ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_SUBSCRIBER (
SUBSCRIBER_ID INTEGER AUTO_INCREMENT,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EMAIL_ADDRESS VARCHAR(256) NULL,
DATE_SUBSCRIBED TIMESTAMP NOT NULL,
PRIMARY KEY (SUBSCRIBER_ID),
UNIQUE (TENANT_ID,USER_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APPLICATION (
APPLICATION_ID INTEGER AUTO_INCREMENT,
NAME VARCHAR(100),
SUBSCRIBER_ID INTEGER,
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES APM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_BUSINESS_OWNER(
OWNER_ID INTEGER AUTO_INCREMENT,
OWNER_NAME VARCHAR(200) NOT NULL,
OWNER_EMAIL VARCHAR(300) NOT NULL,
OWNER_DESC VARCHAR(1500),
OWNER_SITE VARCHAR(200),
TENANT_ID INTEGER,
PRIMARY KEY(OWNER_ID),
UNIQUE (OWNER_NAME,OWNER_EMAIL,TENANT_ID)
) ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_BUSINESS_OWNER_PROPERTY(
OWNER_PROP_ID INTEGER AUTO_INCREMENT,
OWNER_ID INTEGER NOT NULL,
NAME VARCHAR(200) NOT NULL,
VALUE VARCHAR(300) NOT NULL,
SHOW_IN_STORE BOOLEAN NOT NULL,
PRIMARY KEY(OWNER_PROP_ID),
FOREIGN KEY(OWNER_ID) REFERENCES APM_BUSINESS_OWNER(OWNER_ID)
) ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APP (
APP_ID INTEGER AUTO_INCREMENT,
APP_PROVIDER VARCHAR(256),
TENANT_ID INTEGER,
APP_NAME VARCHAR(256),
APP_VERSION VARCHAR(30),
CONTEXT VARCHAR(256),
TRACKING_CODE varchar(100),
VISIBLE_ROLES varchar(500),
UUID varchar(500) NOT NULL,
SAML2_SSO_ISSUER varchar(500),
LOG_OUT_URL varchar(500),
APP_ALLOW_ANONYMOUS BOOLEAN NULL,
APP_ENDPOINT varchar(500),
TREAT_AS_SITE BOOLEAN NOT NULL,
PRIMARY KEY(APP_ID),
UNIQUE (APP_PROVIDER,APP_NAME,APP_VERSION,TRACKING_CODE,UUID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_POLICY_GROUP
(
POLICY_GRP_ID INTEGER AUTO_INCREMENT,
NAME VARCHAR(256),
AUTH_SCHEME VARCHAR(50) NULL,
THROTTLING_TIER varchar(512) DEFAULT NULL,
USER_ROLES varchar(512) DEFAULT NULL,
URL_ALLOW_ANONYMOUS BOOLEAN DEFAULT FALSE,
DESCRIPTION VARCHAR(1000) NULL,
PRIMARY KEY (POLICY_GRP_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_POLICY_GROUP_MAPPING
(
POLICY_GRP_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (POLICY_GRP_ID,APP_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APP_URL_MAPPING (
URL_MAPPING_ID INTEGER AUTO_INCREMENT,
APP_ID INTEGER NOT NULL,
HTTP_METHOD VARCHAR(20) NULL,
URL_PATTERN VARCHAR(512) NULL,
SKIP_THROTTLING BOOLEAN DEFAULT FALSE,
POLICY_GRP_ID INTEGER NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID),
PRIMARY KEY(URL_MAPPING_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_ENTITLEMENT_POLICY_PARTIAL (
ENTITLEMENT_POLICY_PARTIAL_ID INTEGER AUTO_INCREMENT,
NAME varchar(256) DEFAULT NULL,
CONTENT varchar(2048) DEFAULT NULL,
SHARED BOOLEAN DEFAULT FALSE,
AUTHOR varchar(256) DEFAULT NULL,
DESCRIPTION VARCHAR(1000) NULL,
TENANT_ID INTEGER NULL,
PRIMARY KEY(ENTITLEMENT_POLICY_PARTIAL_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_POLICY_GRP_PARTIAL_MAPPING (
POLICY_GRP_ID INTEGER NOT NULL,
POLICY_PARTIAL_ID INTEGER NOT NULL,
EFFECT varchar(50),
POLICY_ID varchar(100) DEFAULT NULL,
FOREIGN KEY(POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP(POLICY_GRP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY(POLICY_PARTIAL_ID) REFERENCES APM_ENTITLEMENT_POLICY_PARTIAL(ENTITLEMENT_POLICY_PARTIAL_ID),
PRIMARY KEY(POLICY_GRP_ID, POLICY_PARTIAL_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_SUBSCRIPTION (
SUBSCRIPTION_ID INTEGER AUTO_INCREMENT,
SUBSCRIPTION_TYPE VARCHAR(50),
TIER_ID VARCHAR(50),
APP_ID INTEGER,
LAST_ACCESSED TIMESTAMP NULL,
APPLICATION_ID INTEGER,
SUB_STATUS VARCHAR(50),
TRUSTED_IDP VARCHAR(255) NULL,
SUBSCRIPTION_TIME TIMESTAMP NOT NULL,
FOREIGN KEY(APPLICATION_ID) REFERENCES APM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (SUBSCRIPTION_ID),
UNIQUE(APP_ID, APPLICATION_ID,SUBSCRIPTION_TYPE)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APP_LC_EVENT (
EVENT_ID INTEGER AUTO_INCREMENT,
APP_ID INTEGER NOT NULL,
PREVIOUS_STATE VARCHAR(50),
NEW_STATE VARCHAR(50) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EVENT_DATE TIMESTAMP NOT NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (EVENT_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_TIER_PERMISSIONS (
TIER_PERMISSIONS_ID INTEGER AUTO_INCREMENT,
TIER VARCHAR(50) NOT NULL,
PERMISSIONS_TYPE VARCHAR(50) NOT NULL,
ROLES VARCHAR(512) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(TIER_PERMISSIONS_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_WORKFLOWS(
WF_ID INTEGER AUTO_INCREMENT,
WF_REFERENCE VARCHAR(255) NOT NULL,
WF_TYPE VARCHAR(255) NOT NULL,
WF_STATUS VARCHAR(255) NOT NULL,
WF_CREATED_TIME TIMESTAMP,
WF_UPDATED_TIME TIMESTAMP,
WF_STATUS_DESC VARCHAR(1000),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL,
PRIMARY KEY (WF_ID),
UNIQUE (WF_EXTERNAL_REFERENCE)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_API_CONSUMER_APPS (
ID INTEGER AUTO_INCREMENT,
SAML2_SSO_ISSUER varchar(500),
APP_CONSUMER_KEY VARCHAR(512),
API_TOKEN_ENDPOINT VARCHAR (1024),
API_CONSUMER_KEY VARCHAR(512),
API_CONSUMER_SECRET VARCHAR(512),
APP_NAME VARCHAR(512),
PRIMARY KEY (ID, APP_CONSUMER_KEY),
FOREIGN KEY (APP_CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) ON UPDATE CASCADE
)ENGINE INNODB;
CREATE INDEX IDX_APM_APP_UUID ON APM_APP (UUID);
CREATE INDEX IDX_APM_SUBSCRIBER_USER_ID ON APM_SUBSCRIBER (USER_ID);
CREATE TABLE IF NOT EXISTS APM_APP_HITS (
UUID VARCHAR(500) NOT NULL,
APP_NAME VARCHAR(200) NOT NULL,
VERSION VARCHAR(50),
CONTEXT VARCHAR(256) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER,
HIT_TIME TIMESTAMP NOT NULL,
PRIMARY KEY (UUID, USER_ID, TENANT_ID, HIT_TIME)
) ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APP_JAVA_POLICY
(
JAVA_POLICY_ID INTEGER AUTO_INCREMENT,
DISPLAY_NAME VARCHAR(100) NOT NULL,
FULL_QUALIFI_NAME VARCHAR(256) NOT NULL,
DESCRIPTION VARCHAR(2500),
DISPLAY_ORDER_SEQ_NO INTEGER NOT NULL,
IS_MANDATORY BOOLEAN DEFAULT FALSE,
POLICY_PROPERTIES VARCHAR(512) NULL,
IS_GLOBAL BOOLEAN DEFAULT TRUE,
PRIMARY KEY(JAVA_POLICY_ID),
UNIQUE(FULL_QUALIFI_NAME,DISPLAY_ORDER_SEQ_NO)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APP_JAVA_POLICY_MAPPING
(
JAVA_POLICY_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
PRIMARY KEY (JAVA_POLICY_ID,APP_ID),
FOREIGN KEY (JAVA_POLICY_ID) REFERENCES APM_APP_JAVA_POLICY(JAVA_POLICY_ID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_EXTERNAL_STORES (
APP_STORE_ID INTEGER AUTO_INCREMENT,
APP_ID INTEGER,
STORE_ID VARCHAR(255) NOT NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (APP_STORE_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_APP_DEFAULT_VERSION (
DEFAULT_VERSION_ID INTEGER AUTO_INCREMENT,
APP_NAME VARCHAR(256),
APP_PROVIDER VARCHAR(256),
DEFAULT_APP_VERSION VARCHAR(30),
PUBLISHED_DEFAULT_APP_VERSION VARCHAR(30),
TENANT_ID INTEGER,
PRIMARY KEY(DEFAULT_VERSION_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_FAVOURITE_APPS (
ID INTEGER AUTO_INCREMENT,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID),
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
UNIQUE (TENANT_ID,USER_ID,APP_ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_STORE_FAVOURITE_PAGE (
ID INTEGER AUTO_INCREMENT,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID_OF_USER INTEGER NOT NULL,
TENANT_ID_OF_STORE INTEGER NOT NULL,
PRIMARY KEY (ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APM_ONE_TIME_DOWNLOAD_LINK(
ID INTEGER AUTO_INCREMENT,
BINARY_FILE varchar(500) NOT NULL,
UUID varchar(500) NOT NULL,
IS_DOWNLOADED BOOLEAN NOT NULL,
USERNAME VARCHAR(255),
TENANT_ID INTEGER,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID)
)ENGINE INNODB;
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY, IS_GLOBAL )
VALUES ('Reverse Proxy Handler','org.wso2.carbon.appmgt.gateway.handlers.proxy.ReverseProxyHandler','',1,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('SAML2 Authentication Handler','org.wso2.carbon.appmgt.gateway.handlers.security.authentication.SAML2AuthenticationHandler','',2,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Subscription Handler', 'org.wso2.carbon.appmgt.gateway.handlers.subscription.SubscriptionsHandler', '', 3,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Authorization Handler', 'org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.AuthorizationHandler','',4,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Entitlement Handler','org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.EntitlementHandler','',5,TRUE,TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY, POLICY_PROPERTIES,IS_GLOBAL )
VALUES ('API Throttle Handler','org.wso2.carbon.appmgt.gateway.handlers.throttling.APIThrottleHandler','',6,TRUE,'{ "id": "A", "policyKey": "gov:/appmgt/applicationdata/tiers.xml"}',TRUE);
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Publish Statistics:','org.wso2.carbon.appmgt.usage.publisher.APPMgtUsageHandler','',7,FALSE,TRUE);
CREATE INDEX IDX_SUB_APP_ID ON APM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID);

@ -0,0 +1,625 @@
declare
v_sql LONG;
sequence_sql LONG;
trigger_sql LONG;
begin
v_sql:='CREATE TABLE IDN_OAUTH_CONSUMER_APPS (
ID INTEGER,
CONSUMER_KEY VARCHAR2 (255),
CONSUMER_SECRET VARCHAR2 (512),
USERNAME VARCHAR2 (255),
TENANT_ID INTEGER DEFAULT 0,
USER_DOMAIN VARCHAR(50),
APP_NAME VARCHAR2 (255),
OAUTH_VERSION VARCHAR2 (128),
CALLBACK_URL VARCHAR2 (1024),
GRANT_TYPES VARCHAR (1024),
CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY),
PRIMARY KEY (ID))';
sequence_sql:='CREATE SEQUENCE IDN_OAUTH_CONSUMER_APPS_SEQ START WITH 1 INCREMENT BY 1 NOCACHE';
trigger_sql:= 'CREATE OR REPLACE TRIGGER IDN_OAUTH_CONSUMER_APPS_TRIG
BEFORE INSERT
ON IDN_OAUTH_CONSUMER_APPS
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT IDN_OAUTH_CONSUMER_APPS_SEQ.nextval INTO :NEW.ID FROM dual;
END';
execute immediate v_sql;
execute immediate sequence_sql;
execute immediate trigger_sql;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -955 THEN
NULL; -- suppresses ORA-00955 exception
ELSE
RAISE;
END IF;
END;
/
CREATE TABLE APM_SUBSCRIBER (
SUBSCRIBER_ID INTEGER,
USER_ID VARCHAR2(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EMAIL_ADDRESS VARCHAR2(256) NULL,
DATE_SUBSCRIBED TIMESTAMP NOT NULL,
PRIMARY KEY (SUBSCRIBER_ID),
UNIQUE (TENANT_ID,USER_ID)
)
/
CREATE SEQUENCE APM_SUBSCRIBER_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_SUBSCRIBER_TRG
BEFORE INSERT
ON APM_SUBSCRIBER
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_SUBSCRIBER_SEQ.nextval INTO :NEW.SUBSCRIBER_ID FROM dual;
END;
/
CREATE INDEX IDX_APM_SUBSCRIBER_USER_ID ON APM_SUBSCRIBER (USER_ID)
/
CREATE TABLE APM_APPLICATION (
APPLICATION_ID INTEGER,
NAME VARCHAR2(100),
SUBSCRIBER_ID INTEGER,
APPLICATION_TIER VARCHAR2(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR2(512),
DESCRIPTION VARCHAR2(512),
APPLICATION_STATUS VARCHAR2(50) DEFAULT 'APPROVED',
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES APM_SUBSCRIBER(SUBSCRIBER_ID),
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
)
/
CREATE SEQUENCE APM_APPLICATION_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_APPLICATION_TRG
BEFORE INSERT
ON APM_APPLICATION
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_APPLICATION_SEQ.nextval INTO :NEW.APPLICATION_ID FROM dual;
END;
/
CREATE TABLE APM_BUSINESS_OWNER(
OWNER_ID INTEGER,
OWNER_NAME VARCHAR2(200) NOT NULL,
OWNER_EMAIL VARCHAR2(300) NOT NULL,
OWNER_DESC VARCHAR2(1500),
OWNER_SITE VARCHAR2(200),
TENANT_ID INTEGER,
PRIMARY KEY(OWNER_ID),
UNIQUE (OWNER_NAME,OWNER_EMAIL,TENANT_ID)
)
/
CREATE SEQUENCE APM_BUSINESS_OWNER_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_BUSINESS_OWNER_TRG
BEFORE INSERT
ON APM_BUSINESS_OWNER
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_BUSINESS_OWNER_SEQ.nextval INTO :NEW.OWNER_ID FROM dual;
END;
/
CREATE TABLE APM_BUSINESS_OWNER_PROPERTY(
OWNER_PROP_ID INTEGER NOT NULL,
OWNER_ID INTEGER NOT NULL,
NAME VARCHAR2(200) NOT NULL,
VALUE VARCHAR2(300) NOT NULL,
SHOW_IN_STORE NUMBER(1) NOT NULL,
PRIMARY KEY(OWNER_PROP_ID),
FOREIGN KEY(OWNER_ID) REFERENCES APM_BUSINESS_OWNER(OWNER_ID)
)
/
CREATE SEQUENCE APM_BUSINESS_OWNER_PROP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_BUSINESS_OWNER_PROP_TRG
BEFORE INSERT
ON APM_BUSINESS_OWNER_PROPERTY
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_BUSINESS_OWNER_PROP_SEQ.nextval INTO :NEW.OWNER_PROP_ID FROM dual;
END;
/
CREATE TABLE APM_APP (
APP_ID INTEGER,
APP_PROVIDER VARCHAR2(256),
TENANT_ID INTEGER,
APP_NAME VARCHAR2(256),
APP_VERSION VARCHAR2(30),
CONTEXT VARCHAR2(256),
TRACKING_CODE VARCHAR2(100),
VISIBLE_ROLES VARCHAR2(500),
UUID VARCHAR2(500) NOT NULL,
SAML2_SSO_ISSUER VARCHAR2(500),
LOG_OUT_URL VARCHAR2(500),
APP_ALLOW_ANONYMOUS NUMBER(1) NULL,
APP_ENDPOINT VARCHAR2(500),
TREAT_AS_SITE NUMBER(1) NOT NULL,
PRIMARY KEY(APP_ID),
UNIQUE (APP_PROVIDER,APP_NAME,APP_VERSION,TRACKING_CODE,UUID)
)
/
CREATE SEQUENCE APM_APP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_APP_TRG
BEFORE INSERT
ON APM_APP
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_APP_SEQ.nextval INTO :NEW.APP_ID FROM dual;
END;
/
CREATE INDEX IDX_APM_APP_UUID ON APM_APP (UUID)
/
CREATE TABLE APM_POLICY_GROUP
(
POLICY_GRP_ID INTEGER,
NAME VARCHAR2(256),
AUTH_SCHEME VARCHAR2(50) NULL,
THROTTLING_TIER VARCHAR2(512) DEFAULT NULL,
USER_ROLES VARCHAR2(512) DEFAULT NULL,
URL_ALLOW_ANONYMOUS NUMBER(1) DEFAULT 0,
DESCRIPTION VARCHAR2(1000) NULL,
PRIMARY KEY (POLICY_GRP_ID)
)
/
CREATE SEQUENCE APM_POLICY_GROUP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_POLICY_GROUP_TRG
BEFORE INSERT
ON APM_POLICY_GROUP
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_POLICY_GROUP_SEQ.nextval INTO :NEW.POLICY_GRP_ID FROM dual;
END;
/
CREATE TABLE APM_POLICY_GROUP_MAPPING
(
POLICY_GRP_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID) ON DELETE CASCADE,
PRIMARY KEY (POLICY_GRP_ID,APP_ID)
)
/
CREATE TABLE APM_APP_URL_MAPPING (
URL_MAPPING_ID INTEGER,
APP_ID INTEGER NOT NULL,
HTTP_METHOD VARCHAR2(20) NULL,
URL_PATTERN VARCHAR2(512) NULL,
SKIP_THROTTLING NUMBER(1) DEFAULT 0,
POLICY_GRP_ID INTEGER NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
FOREIGN KEY (POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP (POLICY_GRP_ID),
PRIMARY KEY(URL_MAPPING_ID)
)
/
CREATE SEQUENCE APM_APP_URL_MAPPING_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_APP_URL_MAPPING_TRG
BEFORE INSERT
ON APM_APP_URL_MAPPING
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_APP_URL_MAPPING_SEQ.nextval INTO :NEW.URL_MAPPING_ID FROM dual;
END;
/
CREATE TABLE APM_ENTITLEMENT_POLICY_PARTIAL (
ENTITLEMENT_POLICY_PARTIAL_ID INTEGER,
NAME VARCHAR2(256) DEFAULT NULL,
CONTENT VARCHAR2(2048) DEFAULT NULL,
"SHARED" NUMBER(1) DEFAULT 0,
AUTHOR VARCHAR2(256) DEFAULT NULL,
DESCRIPTION VARCHAR2(1000) NULL,
TENANT_ID INT NULL,
PRIMARY KEY(ENTITLEMENT_POLICY_PARTIAL_ID)
)
/
-- Breaking the naming convention since the identifer name is too long.
CREATE SEQUENCE APM_ENTL_POLICY_PARTIAL_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
-- Breaking the naming convention since the identifer name is too long.
CREATE OR REPLACE TRIGGER APM_ENTL_POLICY_PARTIAL_TRG
BEFORE INSERT
ON APM_ENTITLEMENT_POLICY_PARTIAL
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_ENTL_POLICY_PARTIAL_SEQ.nextval INTO :NEW.ENTITLEMENT_POLICY_PARTIAL_ID FROM dual;
END;
/
CREATE TABLE APM_POLICY_GRP_PARTIAL_MAPPING (
POLICY_GRP_ID INTEGER NOT NULL,
POLICY_PARTIAL_ID INTEGER NOT NULL,
EFFECT VARCHAR2(50),
POLICY_ID VARCHAR2(100) DEFAULT NULL,
FOREIGN KEY(POLICY_GRP_ID) REFERENCES APM_POLICY_GROUP(POLICY_GRP_ID) ON DELETE CASCADE,
FOREIGN KEY(POLICY_PARTIAL_ID) REFERENCES APM_ENTITLEMENT_POLICY_PARTIAL(ENTITLEMENT_POLICY_PARTIAL_ID),
PRIMARY KEY(POLICY_GRP_ID, POLICY_PARTIAL_ID)
)
/
CREATE TABLE APM_SUBSCRIPTION (
SUBSCRIPTION_ID INTEGER,
SUBSCRIPTION_TYPE VARCHAR2(50),
TIER_ID VARCHAR2(50),
APP_ID INTEGER,
LAST_ACCESSED TIMESTAMP NULL,
APPLICATION_ID INTEGER,
SUB_STATUS VARCHAR2(50),
TRUSTED_IDP VARCHAR2(255) NULL,
SUBSCRIPTION_TIME TIMESTAMP NOT NULL,
FOREIGN KEY(APPLICATION_ID) REFERENCES APM_APPLICATION(APPLICATION_ID),
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID),
PRIMARY KEY (SUBSCRIPTION_ID),
UNIQUE(APP_ID, APPLICATION_ID,SUBSCRIPTION_TYPE)
)
/
CREATE SEQUENCE APM_SUBSCRIPTION_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_SUBSCRIPTION_TRG
BEFORE INSERT
ON APM_SUBSCRIPTION
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_SUBSCRIPTION_SEQ.nextval INTO :NEW.SUBSCRIPTION_ID FROM dual;
END;
/
CREATE INDEX IDX_SUB_APP_ID ON APM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID)
/
CREATE TABLE APM_APP_LC_EVENT (
EVENT_ID INTEGER,
APP_ID INTEGER NOT NULL,
PREVIOUS_STATE VARCHAR2(50),
NEW_STATE VARCHAR2(50) NOT NULL,
USER_ID VARCHAR2(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EVENT_DATE TIMESTAMP NOT NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID),
PRIMARY KEY (EVENT_ID)
)
/
CREATE SEQUENCE APM_APP_LC_EVENT_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_APP_LC_EVENT_TRG
BEFORE INSERT
ON APM_APP_LC_EVENT
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_APP_LC_EVENT_SEQ.nextval INTO :NEW.EVENT_ID FROM dual;
END;
/
CREATE TABLE APM_TIER_PERMISSIONS (
TIER_PERMISSIONS_ID INTEGER,
TIER VARCHAR2(50) NOT NULL,
PERMISSIONS_TYPE VARCHAR2(50) NOT NULL,
ROLES VARCHAR2(512) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(TIER_PERMISSIONS_ID)
)
/
CREATE SEQUENCE APM_TIER_PERMISSIONS_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_TIER_PERMISSIONS_TRG
BEFORE INSERT
ON APM_TIER_PERMISSIONS
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_TIER_PERMISSIONS_SEQ.nextval INTO :NEW.TIER_PERMISSIONS_ID FROM dual;
END;
/
CREATE TABLE APM_WORKFLOWS(
WF_ID INTEGER,
WF_REFERENCE VARCHAR2(255) NOT NULL,
WF_TYPE VARCHAR2(255) NOT NULL,
WF_STATUS VARCHAR2(255) NOT NULL,
WF_CREATED_TIME TIMESTAMP,
WF_UPDATED_TIME TIMESTAMP,
WF_STATUS_DESC VARCHAR2(1000),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR2(255),
WF_EXTERNAL_REFERENCE VARCHAR2(255) NOT NULL,
PRIMARY KEY (WF_ID),
UNIQUE (WF_EXTERNAL_REFERENCE)
)
/
CREATE SEQUENCE APM_WORKFLOWS_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_WORKFLOWS_TRG
BEFORE INSERT
ON APM_WORKFLOWS
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_WORKFLOWS_SEQ.nextval INTO :NEW.WF_ID FROM dual;
END;
/
-- TODO : Add Foreign key contraints for APP_CONSUMER_KEY --> IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) and (SAML2_SSO_ISSUER) --> APM_APP(SAML2_SSO_ISSUER)
CREATE TABLE APM_API_CONSUMER_APPS(
ID INTEGER,
SAML2_SSO_ISSUER VARCHAR2(500),
APP_CONSUMER_KEY VARCHAR2(512),
API_TOKEN_ENDPOINT VARCHAR2(1024),
API_CONSUMER_KEY VARCHAR2(512),
API_CONSUMER_SECRET VARCHAR2(512),
APP_NAME VARCHAR2(512),
PRIMARY KEY (ID, APP_CONSUMER_KEY)
)
/
CREATE SEQUENCE APM_API_CONSUMER_APPS_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_API_CONSUMER_APPS_TRG
BEFORE INSERT
ON APM_API_CONSUMER_APPS
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_API_CONSUMER_APPS_SEQ.nextval INTO :NEW.ID FROM dual;
END;
/
CREATE TABLE APM_APP_HITS (
UUID VARCHAR2(500) NOT NULL,
APP_NAME VARCHAR2(200) NOT NULL,
VERSION VARCHAR2(50),
CONTEXT VARCHAR2(256) NOT NULL,
USER_ID VARCHAR2(50) NOT NULL,
TENANT_ID INTEGER,
HIT_TIME TIMESTAMP NOT NULL,
PRIMARY KEY (UUID, USER_ID, TENANT_ID, HIT_TIME)
)
/
CREATE TABLE APM_APP_JAVA_POLICY(
JAVA_POLICY_ID INTEGER,
DISPLAY_NAME VARCHAR2(100) NOT NULL,
FULL_QUALIFI_NAME VARCHAR2(256) NOT NULL,
DESCRIPTION VARCHAR2(2500),
DISPLAY_ORDER_SEQ_NO INTEGER NOT NULL,
IS_MANDATORY NUMBER(1) DEFAULT 0,
POLICY_PROPERTIES VARCHAR2(512) NULL,
IS_GLOBAL NUMBER(1) DEFAULT 1,
PRIMARY KEY(JAVA_POLICY_ID),
UNIQUE(FULL_QUALIFI_NAME,DISPLAY_ORDER_SEQ_NO)
)
/
CREATE SEQUENCE APM_APP_JAVA_POLICY_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_APP_JAVA_POLICY_TRG
BEFORE INSERT
ON APM_APP_JAVA_POLICY
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_APP_JAVA_POLICY_SEQ.nextval INTO :NEW.JAVA_POLICY_ID FROM dual;
END;
/
CREATE TABLE APM_APP_JAVA_POLICY_MAPPING(
JAVA_POLICY_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
PRIMARY KEY (JAVA_POLICY_ID,APP_ID),
FOREIGN KEY (JAVA_POLICY_ID) REFERENCES APM_APP_JAVA_POLICY(JAVA_POLICY_ID) ON DELETE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE
)
/
CREATE TABLE APM_EXTERNAL_STORES (
APP_STORE_ID INTEGER,
APP_ID INTEGER,
STORE_ID VARCHAR2(255) NOT NULL,
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
PRIMARY KEY (APP_STORE_ID)
)
/
CREATE SEQUENCE APM_EXTERNAL_STORES_SEQ START WITH 1 INCREMENT BY 1
/
CREATE OR REPLACE TRIGGER APM_EXTERNAL_STORES_TRG
BEFORE INSERT
ON APM_EXTERNAL_STORES
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_EXTERNAL_STORES_SEQ.nextval INTO :NEW.APP_STORE_ID FROM dual;
END;
/
CREATE TABLE APM_APP_DEFAULT_VERSION (
DEFAULT_VERSION_ID INTEGER,
APP_NAME VARCHAR2(256),
APP_PROVIDER VARCHAR2(256),
DEFAULT_APP_VERSION VARCHAR2(30),
PUBLISHED_DEFAULT_APP_VERSION VARCHAR2(30),
TENANT_ID INTEGER,
PRIMARY KEY(DEFAULT_VERSION_ID)
)
/
CREATE SEQUENCE APM_APP_DEFAULT_VERSION_SEQ START WITH 1 INCREMENT BY 1
/
CREATE OR REPLACE TRIGGER APM_APP_DEFAULT_VERSION_TRG
BEFORE INSERT
ON APM_APP_DEFAULT_VERSION
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_APP_DEFAULT_VERSION_SEQ.nextval INTO :NEW.DEFAULT_VERSION_ID FROM dual;
END;
/
CREATE TABLE APM_FAVOURITE_APPS (
ID INTEGER ,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
APP_ID INTEGER NOT NULL,
CREATED_TIME DATE NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY(APP_ID) REFERENCES APM_APP(APP_ID) ON DELETE CASCADE,
UNIQUE (TENANT_ID,USER_ID,APP_ID)
)
/
CREATE SEQUENCE APM_FAVOURITE_APPS_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_FAVOURITE_APPS_TRG
BEFORE INSERT
ON APM_FAVOURITE_APPS
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_FAVOURITE_APPS_SEQ.nextval INTO :NEW.ID FROM dual;
END;
/
CREATE TABLE APM_STORE_FAVOURITE_PAGE (
ID INTEGER ,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID_OF_USER INTEGER NOT NULL,
TENANT_ID_OF_STORE INTEGER NOT NULL,
PRIMARY KEY (ID)
)
/
CREATE SEQUENCE APM_STORE_FAVOURITE_PAGE_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_STORE_FAVOURITE_PAGE_TRG
BEFORE INSERT
ON APM_STORE_FAVOURITE_PAGE
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_STORE_FAVOURITE_PAGE_SEQ.nextval INTO :NEW.ID FROM dual;
END;
/
CREATE TABLE APM_ONE_TIME_DOWNLOAD_LINK (
ID INTEGER,
BINARY_FILE VARCHAR(500) NOT NULL,
UUID VARCHAR(500) NOT NULL,
IS_DOWNLOADED NUMBER(1) NOT NULL,
USERNAME VARCHAR(255),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID)
)
/
CREATE SEQUENCE APM_ONE_TIME_DOWNLOAD_LINK_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER APM_ONE_TIME_DOWNLOAD_LINK_TRG
BEFORE INSERT
ON APM_ONE_TIME_DOWNLOAD_LINK
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT APM_ONE_TIME_DOWNLOAD_LINK_SEQ.nextval INTO :NEW.ID FROM dual;
END;
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY, IS_GLOBAL )
VALUES ('Reverse Proxy Handler','org.wso2.carbon.appmgt.gateway.handlers.proxy.ReverseProxyHandler','',1,1,1)
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('SAML2 Authentication Handler','org.wso2.carbon.appmgt.gateway.handlers.security.authentication.SAML2AuthenticationHandler','',2,1,1)
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Subscription Handler', 'org.wso2.carbon.appmgt.gateway.handlers.subscription.SubscriptionsHandler','',3,1,1)
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Authorization Handler', 'org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.AuthorizationHandler','',4,1,1)
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Entitlement Handler','org.wso2.carbon.appmgt.gateway.handlers.security.entitlement.EntitlementHandler','',5,1,1)
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY, POLICY_PROPERTIES,IS_GLOBAL )
VALUES ('API Throttle Handler','org.wso2.carbon.appmgt.gateway.handlers.throttling.APIThrottleHandler','',6,1,'{ "id": "A", "policyKey": "gov:/appmgt/applicationdata/tiers.xml"}',1)
/
INSERT INTO APM_APP_JAVA_POLICY(DISPLAY_NAME, FULL_QUALIFI_NAME, DESCRIPTION, DISPLAY_ORDER_SEQ_NO,IS_MANDATORY,IS_GLOBAL)
VALUES ('Publish Statistics:','org.wso2.carbon.appmgt.usage.publisher.APPMgtUsageHandler','',7,0,1)
/

@ -0,0 +1,310 @@
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS IDN_BASE_TABLE (
PRODUCT_NAME VARCHAR (20),
PRIMARY KEY (PRODUCT_NAME)
)
;
INSERT INTO IDN_BASE_TABLE values ('WSO2 Identity Server');
CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS (
CONSUMER_KEY VARCHAR (512),
CONSUMER_SECRET VARCHAR (512),
USERNAME VARCHAR (255),
TENANT_ID INTEGER DEFAULT 0,
APP_NAME VARCHAR (255),
OAUTH_VERSION VARCHAR (128),
CALLBACK_URL VARCHAR (1024),
GRANT_TYPES VARCHAR (1024),
PRIMARY KEY (CONSUMER_KEY)
)
;
CREATE TABLE IF NOT EXISTS IDN_OAUTH1A_REQUEST_TOKEN (
REQUEST_TOKEN VARCHAR (512),
REQUEST_TOKEN_SECRET VARCHAR (512),
CONSUMER_KEY VARCHAR (512),
CALLBACK_URL VARCHAR (1024),
SCOPE VARCHAR(2048),
AUTHORIZED VARCHAR (128),
OAUTH_VERIFIER VARCHAR (512),
AUTHZ_USER VARCHAR (512),
PRIMARY KEY (REQUEST_TOKEN),
FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY)
)
;
CREATE TABLE IF NOT EXISTS IDN_OAUTH1A_ACCESS_TOKEN (
ACCESS_TOKEN VARCHAR (512),
ACCESS_TOKEN_SECRET VARCHAR (512),
CONSUMER_KEY VARCHAR (512),
SCOPE VARCHAR(2048),
AUTHZ_USER VARCHAR (512),
PRIMARY KEY (ACCESS_TOKEN),
FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY)
)
;
CREATE TABLE IF NOT EXISTS IDN_OAUTH2_AUTHORIZATION_CODE (
AUTHORIZATION_CODE VARCHAR (512),
CONSUMER_KEY VARCHAR (512),
SCOPE VARCHAR(2048),
AUTHZ_USER VARCHAR (512),
TIME_CREATED TIMESTAMP,
VALIDITY_PERIOD BIGINT,
PRIMARY KEY (AUTHORIZATION_CODE),
FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY)
)
;
CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN (
ACCESS_TOKEN VARCHAR (255),
REFRESH_TOKEN VARCHAR (255),
CONSUMER_KEY VARCHAR (255),
AUTHZ_USER VARCHAR (255),
USER_TYPE VARCHAR (255),
TIME_CREATED TIMESTAMP,
VALIDITY_PERIOD BIGINT,
TOKEN_SCOPE VARCHAR (25),
TOKEN_STATE VARCHAR (25) DEFAULT 'ACTIVE',
TOKEN_STATE_ID VARCHAR (255) DEFAULT 'NONE',
PRIMARY KEY (ACCESS_TOKEN),
FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY)
)
;
CREATE TABLE IF NOT EXISTS IDN_OPENID_USER_RPS (
USER_NAME VARCHAR(255) NOT NULL,
TENANT_ID INTEGER DEFAULT 0,
RP_URL VARCHAR(255) NOT NULL,
TRUSTED_ALWAYS VARCHAR(128) DEFAULT 'FALSE',
LAST_VISIT DATE NOT NULL,
VISIT_COUNT INTEGER DEFAULT 0,
DEFAULT_PROFILE_NAME VARCHAR(255) DEFAULT 'DEFAULT',
PRIMARY KEY (USER_NAME, TENANT_ID, RP_URL)
)
;
CREATE SEQUENCE AM_SUBSCRIBER_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_SUBSCRIBER (
SUBSCRIBER_ID INTEGER DEFAULT nextval('am_subscriber_sequence'),
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EMAIL_ADDRESS VARCHAR(256) NULL,
DATE_SUBSCRIBED DATE NOT NULL,
PRIMARY KEY (SUBSCRIBER_ID),
UNIQUE (TENANT_ID,USER_ID)
)
;
CREATE SEQUENCE AM_APPLICATION_SEQUENCE START WITH 1 INCREMENT BY 1 ;
CREATE TABLE IF NOT EXISTS AM_APPLICATION (
APPLICATION_ID INTEGER DEFAULT nextval('am_application_sequence'),
NAME VARCHAR(100),
SUBSCRIBER_ID INTEGER,
APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited',
CALLBACK_URL VARCHAR(512),
DESCRIPTION VARCHAR(512),
APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED',
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID),
UNIQUE (NAME,SUBSCRIBER_ID)
)
;
CREATE SEQUENCE APM_BUSINESS_OWNER_SEQUENCE START WITH 1 INCREMENT BY 1 ;
CREATE TABLE IF NOT EXISTS APM_BUSINESS_OWNER(
OWNER_ID INTEGER DEFAULT nextval('apm_business_owner_sequence'),
OWNER_NAME VARCHAR(200) NOT NULL,
OWNER_EMAIL VARCHAR(300) NOT NULL,
OWNER_DESC VARCHAR(1500),
OWNER_SITE VARCHAR(200),
TENANT_ID INTEGER,
PRIMARY KEY(OWNER_ID),
UNIQUE (OWNER_NAME,OWNER_EMAIL,TENANT_ID)
);
CREATE SEQUENCE APM_BUSINESS_OWNER_PROPERTY_SEQUENCE START WITH 1 INCREMENT BY 1 ;
CREATE TABLE IF NOT EXISTS APM_BUSINESS_OWNER_PROPERTY(
OWNER_PROP_ID INTEGER DEFAULT nextval('apm_business_owner_property_sequence'),
OWNER_ID INTEGER NOT NULL,
NAME VARCHAR(200) NOT NULL,
VALUE VARCHAR(300) NOT NULL,
SHOW_IN_STORE BOOLEAN NOT NULL,
PRIMARY KEY(OWNER_PROP_ID),
FOREIGN KEY(OWNER_ID) REFERENCES APM_BUSINESS_OWNER(OWNER_ID)
);
CREATE SEQUENCE APPMGR_APP_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS APPMGR_APP (
API_ID INTEGER DEFAULT nextval('appmgr_app_sequence'),
API_PROVIDER VARCHAR(256),
API_NAME VARCHAR(256),
API_VERSION VARCHAR(30),
CONTEXT VARCHAR(256),
PRIMARY KEY(API_ID),
UNIQUE (API_PROVIDER,API_NAME,API_VERSION)
)
;
CREATE SEQUENCE APPMGR_APP_URL_MAPPING_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS APPMGR_APP_URL_MAPPING (
URL_MAPPING_ID INTEGER DEFAULT nextval('appmgr_app_url_mapping_sequence'),
API_ID INTEGER NOT NULL,
HTTP_METHOD VARCHAR(20) NULL,
AUTH_SCHEME VARCHAR(50) NULL,
URL_PATTERN VARCHAR(512) NULL,
THROTTLING_TIER varchar(512) DEFAULT NULL,
USER_ROLES varchar(512) DEFAULT NULL,
ENTITLEMENT_POLICY_ID varchar(512) DEFAULT NULL,
PRIMARY KEY(URL_MAPPING_ID)
)
;
CREATE SEQUENCE AM_SUBSCRIPTION_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION (
SUBSCRIPTION_ID INTEGER DEFAULT nextval('am_subscription_sequence'),
SUBSCRIPTION_TYPE VARCHAR(50),
TIER_ID VARCHAR(50),
API_ID INTEGER,
LAST_ACCESSED DATE NULL,
APPLICATION_ID INTEGER,
SUB_STATUS VARCHAR(50),
FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY(API_ID) REFERENCES APPMGR_APP(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (SUBSCRIPTION_ID)
)
;
CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION_KEY_MAPPING (
SUBSCRIPTION_ID INTEGER,
ACCESS_TOKEN VARCHAR(512),
KEY_TYPE VARCHAR(512) NOT NULL,
FOREIGN KEY(SUBSCRIPTION_ID) REFERENCES AM_SUBSCRIPTION(SUBSCRIPTION_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(SUBSCRIPTION_ID,ACCESS_TOKEN)
)
;
CREATE TABLE IF NOT EXISTS AM_APPLICATION_KEY_MAPPING (
APPLICATION_ID INTEGER,
CONSUMER_KEY VARCHAR(512),
KEY_TYPE VARCHAR(512) NOT NULL,
FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY(APPLICATION_ID,CONSUMER_KEY)
)
;
CREATE SEQUENCE APPMGR_APP_LC_EVENT_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS APPMGR_APP_LC_EVENT (
EVENT_ID INTEGER DEFAULT nextval('appmgr_app_lc_event_sequence'),
API_ID INTEGER NOT NULL,
PREVIOUS_STATE VARCHAR(50),
NEW_STATE VARCHAR(50) NOT NULL,
USER_ID VARCHAR(50) NOT NULL,
TENANT_ID INTEGER NOT NULL,
EVENT_DATE DATE NOT NULL,
FOREIGN KEY(API_ID) REFERENCES APPMGR_APP(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (EVENT_ID)
)
;
CREATE TABLE IF NOT EXISTS AM_APP_KEY_DOMAIN_MAPPING (
CONSUMER_KEY VARCHAR(255),
AUTHZ_DOMAIN VARCHAR(255) DEFAULT 'ALL',
PRIMARY KEY (CONSUMER_KEY,AUTHZ_DOMAIN),
FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY)
)
;
CREATE SEQUENCE APPMGR_APP_COMMENTS_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS APPMGR_APP_COMMENTS (
COMMENT_ID INTEGER DEFAULT nextval('appmgr_app_comments_sequence'),
COMMENT_TEXT VARCHAR(512),
COMMENTED_USER VARCHAR(255),
DATE_COMMENTED DATE NOT NULL,
API_ID INTEGER NOT NULL,
FOREIGN KEY(API_ID) REFERENCES APPMGR_APP(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (COMMENT_ID)
)
;
CREATE SEQUENCE AM_WORKFLOWS_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_WORKFLOWS(
WF_ID INTEGER DEFAULT nextval('am_workflows_sequence'),
WF_REFERENCE VARCHAR(255) NOT NULL,
WF_TYPE VARCHAR(255) NOT NULL,
WF_STATUS VARCHAR(255) NOT NULL,
WF_CREATED_TIME TIMESTAMP,
WF_UPDATED_TIME TIMESTAMP,
WF_STATUS_DESC VARCHAR(1000),
TENANT_ID INTEGER,
TENANT_DOMAIN VARCHAR(255),
WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL,
PRIMARY KEY (WF_ID),
UNIQUE (WF_EXTERNAL_REFERENCE)
)
;
CREATE SEQUENCE APPMGR_APP_RATINGS_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS APPMGR_APP_RATINGS (
RATING_ID INTEGER DEFAULT nextval('appmgr_app_ratings_sequence'),
API_ID INTEGER,
RATING INTEGER,
SUBSCRIBER_ID INTEGER,
FOREIGN KEY(API_ID) REFERENCES APPMGR_APP(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (RATING_ID)
)
;
CREATE SEQUENCE AM_TIER_PERMISSIONS_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_TIER_PERMISSIONS (
TIER_PERMISSIONS_ID INTEGER DEFAULT nextval('am_tier_permissions_sequence'),
TIER VARCHAR(50) NOT NULL,
PERMISSIONS_TYPE VARCHAR(50) NOT NULL,
ROLES VARCHAR(512) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(TIER_PERMISSIONS_ID)
);
CREATE TABLE IF NOT EXISTS IDN_THRIFT_SESSION (
SESSION_ID VARCHAR(255) NOT NULL,
USER_NAME VARCHAR(255) NOT NULL,
CREATED_TIME VARCHAR(255) NOT NULL,
LAST_MODIFIED_TIME VARCHAR(255) NOT NULL,
PRIMARY KEY (SESSION_ID)
)
;
CREATE SEQUENCE AM_EXTERNAL_STORES_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_EXTERNAL_STORES (
APISTORE_ID INTEGER DEFAULT nextval('am_external_stores_sequence'),
API_ID INTEGER,
STORE_ID VARCHAR(255) NOT NULL,
STORE_DISPLAY_NAME VARCHAR(255) NOT NULL,
STORE_ENDPOINT VARCHAR(255) NOT NULL,
STORE_TYPE VARCHAR(255) NOT NULL,
FOREIGN KEY(API_ID) REFERENCES APPMGR_APP(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (APISTORE_ID)
)
;
CREATE SEQUENCE APM_APP_DEFAULT_VERSION_SEQUENCE START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS APM_APP_DEFAULT_VERSION (
DEFAULT_VERSION_ID INTEGER DEFAULT nextval('apm_app_default_version_sequence'),
APP_NAME VARCHAR(256),
APP_PROVIDER VARCHAR(256),
DEFAULT_APP_VERSION VARCHAR(30),
PUBLISHED_DEFAULT_APP_VERSION VARCHAR(30),
TENANT_ID INTEGER,
PRIMARY KEY(DEFAULT_VERSION_ID)
)
;
CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID)
;
CREATE INDEX IDX_AT_CK_AU ON IDN_OAUTH2_ACCESS_TOKEN(CONSUMER_KEY, AUTHZ_USER, TOKEN_STATE, USER_TYPE);
commit;
Loading…
Cancel
Save