Note that as of 2021.11.R01, MySQL is discouraged for production use due to performance limitations of the database. Smile CDR will continue to support customers on this database, but if serious performance issues arise, we will suggest migrating to a more performant database.

41.4.1Setting Up MySQL

 

This page contains details on how to set up databases for use with MySQL.

41.4.2Supported Versions

 

See platform requirements for information on supported versions of MySQL.

41.4.3Creating a Database for Smile CDR

 

A script similar to the following can be used to create a new database named cdr with username cdr and password SmileCDR in MySQL:

CREATE DATABASE cdr;
USE cdr;
CREATE USER 'cdr'@'%' IDENTIFIED BY 'SmileCDR';
GRANT ALL PRIVILEGES ON cdr.* TO 'cdr'@'%';
SET GLOBAL SQL_MODE=ANSI_QUOTES;
Smile CDR generates database table names wrapped in double-quotes, so you must configure MySQL to respect ANSI_QUOTES, as shown above!

41.4.4Database Connection Properties

 

When configuring Smile CDR to connect to a MySQL database, set the appropriate persistence and cluster manager properties to values similar to the following (making adjustments where necessary, e.g. for hostname, port number, username and password):

module.clustermgr.config.db.driver    =MYSQL_5_7
module.clustermgr.config.db.url       =jdbc:mysql://localhost:3306/cdr?serverTimezone=Canada/Eastern
module.clustermgr.config.db.username  =cdr
module.clustermgr.config.db.password  =SmileCDR

41.4.5Setting up a Cluster Manager Database

 

To initialize a new MySQL database for the Cluster Manager, initialize a database with the following SQL:

create table AG_ADDRESS (
    PID bigint not null,
    ADDRESS_LINE1 varchar(200) not null,
    ADDRESS_LINE2 varchar(200),
    CITY varchar(200) not null,
    COUNTRY varchar(200) not null,
    POSTAL_CODE varchar(200) not null,
    REGION varchar(200) not null,
    AG_PROFILE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_APP_REQUEST (
    PID bigint not null,
    APP_DESCRIPTION varchar(400),
    APP_DEVELOPER_NAME varchar(200),
    APP_HOMEPAGE varchar(200),
    APP_NAME varchar(200) not null,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    MEMBER_COMMENT varchar(200),
    COMPANY_NAME varchar(200),
    EMAIL varchar(200) not null,
    FIRST_NAME varchar(200) not null,
    INDUSTRY varchar(200),
    JOB_TITLE varchar(200),
    LAST_NAME varchar(200) not null,
    NOTE varchar(400),
    REQUEST_STATUS enum ('NEW','INVITATION_SENT') not null,
    SUBSCRIBE_ACCEPTED bit,
    MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table AG_APPL (
    PID bigint not null,
    ATTESTATION_ACCEPTED bit not null,
    BACKEND_SERVICE bit,
    CONFIDENTIAL bit,
    CONFIDENTIAL_TYPE enum ('SECRET','JWK_SET','JWK_SET_URL'),
    JWK_SET_URL varchar(4000),
    HOME_URL varchar(200),
    LAUNCH_URL varchar(200),
    LONG_DESC varchar(4000) not null,
    APP_NAME varchar(200) not null,
    OAUTH_REDIRECT_URL varchar(200) not null,
    PRIVACY_POLICY_URL varchar(200) not null,
    SHORT_DESC varchar(200) not null,
    AG_STATUS enum ('INREVIEW','LIVE','SUSPENDED','REJECTED','RETIRED') not null,
    TERMS_OF_SERVICE_URL varchar(200) not null,
    VERSION_NUMBER bigint,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    IDENTIFIER varchar(200),
    SEED varchar(256),
    VIDEO_URL varchar(200),
    VIDEO_URL_STATUS enum ('INREVIEW','APPROVED','DECLINED'),
    JWK_SET_PID bigint,
    ATTESTATION_PID bigint,
    ICON_PID bigint,
    MODULE_PID bigint not null,
    OAUTH2_CLIENT_PID bigint,
    PARENT_PID bigint,
    PROFILE_PID bigint,
    USER_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_ATTESTATION (
    PID bigint not null,
    ARCHIVE_DATE datetime(6),
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    TITLE varchar(200) not null,
    HTML_PID bigint,
    MODULE_PID bigint not null,
    PLAIN_HTML_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_CLASS (
    PID bigint not null,
    CLASSIFICATION varchar(200) not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_COUNTRY (
    PID bigint not null,
    ISO_CODE_ALPHA2 varchar(2) not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_DATA (
    PID bigint not null,
    DATA_LOB tinyblob,
    DATA_BIN longblob,
    primary key (PID)
) engine=InnoDB;

create table AG_DOCUMENT (
    PID bigint not null,
    FILEACTIVE bit not null,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    FILEDESC varchar(200),
    FILENAME varchar(200) not null,
    FILETYPE varchar(200) not null,
    DOCUMENT_PID bigint not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_DRAFT (
    PID bigint not null,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    BACKEND_SERVICE bit,
    DATA_HASH integer,
    APP_NAME varchar(200) not null,
    DRAFT_PID bigint not null,
    MODULE_PID bigint not null,
    SOURCE_APP_PID bigint,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table AG_MEMBER_PHONE (
    PID bigint not null,
    COUNTRY_CODE varchar(20) not null,
    PHONE_NUMBER varchar(20) not null,
    PHONE_TYPE enum ('WORK','CELL','PERSONAL') not null,
    AG_APP_REQUEST_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_METADATA (
    PID bigint not null,
    METADATA_KEY varchar(100) not null,
    METADATA_SEARCHABLE bit not null,
    METADATA_VALUE varchar(4000) not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_NOTE (
    PID bigint not null,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    MESSAGE varchar(1500) not null,
    REASON varchar(1000) not null,
    NOTE_TYPE enum ('STATE_CHANGE','ASSET_EVALUATION'),
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_OAUTH_REDIRECT (
    PID bigint not null,
    OAUTH_REDIRECT_URL varchar(200) not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_PERMISSION (
    PID bigint not null,
    PERMISSION enum ('CHANGE_OWN_PASSWORD','ACCESS_EASYSHARE','EASYSHARE_CREATE_SMART_HEALTH_LINK','CHANGE_OWN_DEFAULT_LAUNCH_CONTEXTS','CHANGE_OWN_TFA_KEY','ACCESS_ADMIN_WEB','ACCESS_ADMIN_JSON','ACCESS_FHIR_ENDPOINT','ACCESS_FHIRWEB','VIEW_METRICS','VIEW_MODULE_STATUS','VIEW_MODULE_CONFIG','ARCHIVE_MODULE','REINSTATE_MODULE','OPENID_CONNECT_VIEW_CLIENT_LIST','OPENID_CONNECT_VIEW_SERVER_LIST','OPENID_CONNECT_ADD_CLIENT','OIDC_CLIENT_PRESET_PERMISSION','OPENID_CONNECT_ADD_SERVER','OPENID_CONNECT_EDIT_SERVER','OPENID_CONNECT_EDIT_CLIENT','OPENID_CONNECT_MANAGE_GLOBAL_SESSIONS','CREATE_USER','UPDATE_USER','VIEW_USERS','SAVE_USER','ROLE_FHIR_CLIENT','ROLE_SYSTEM','ROLE_SYSTEM_INITIALIZATION','VIEW_AUDIT_LOG','VIEW_TRANSACTION_LOG','VIEW_TRANSACTION_LOG_EVENT','UPDATE_MODULE_CONFIG','START_STOP_MODULE','CONTROL_MODULE','CREATE_MODULE','MODULE_ADMIN','FHIR_ACCESS_PARTITION_ALL','FHIR_ACCESS_PARTITION_NAME','FHIR_OP_BINARY_ACCESS_READ','FHIR_OP_BINARY_ACCESS_WRITE','FHIR_OP_INITIATE_BULK_DATA_EXPORT','FHIR_OP_INITIATE_BULK_DATA_IMPORT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_GROUP','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_ALL_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_SYSTEM','FHIR_READ_SEARCH_PARAMETERS','FHIR_MODIFY_SEARCH_PARAMETERS','FHIR_READ_ALL_IN_COMPARTMENT','FHIR_WRITE_ALL_IN_COMPARTMENT','FHIR_READ_TYPE_IN_COMPARTMENT','FHIR_WRITE_TYPE_IN_COMPARTMENT','FHIR_READ_ALL_OF_TYPE','FHIR_WRITE_ALL_OF_TYPE','FHIR_READ_INSTANCE','FHIR_WRITE_INSTANCE','BLOCK_FHIR_READ_UNLESS_CODE_IN_VS','BLOCK_FHIR_READ_UNLESS_CODE_NOT_IN_VS','FHIR_EXPUNGE_DELETED','FHIR_EXPUNGE_PREVIOUS_VERSIONS','FHIR_EXPUNGE_EVERYTHING','FHIR_DELETE_EXPUNGE','FHIR_LIVEBUNDLE','FHIR_MANAGE_PARTITIONS','FHIR_META_OPERATIONS_SUPERUSER','FHIR_EXTENDED_OPERATION_SUPERUSER','FHIR_EXTENDED_OPERATION_ON_SERVER','FHIR_EXTENDED_OPERATION_ON_TYPE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE_OF_TYPE','FHIR_OP_PATIENT_MATCH','FHIR_OP_MDM_MERGE_GOLDEN_RESOURCES','FHIR_OP_MDM_UPDATE_LINK','FHIR_OP_MDM_CREATE_LINK','FHIR_OP_MDM_QUERY_LINKS','FHIR_OP_MDM_LINK_HISTORY','FHIR_OP_MDM_DUPLICATE_GOLDEN_RESOURCES','FHIR_OP_MDM_NOT_DUPLICATE','FHIR_OP_MDM_CLEAR','FHIR_OP_MDM_SUBMIT','FHIR_MDM_ADMIN','FHIR_OP_EMPI_MERGE_PERSONS','FHIR_OP_EMPI_UPDATE_LINK','FHIR_OP_EMPI_QUERY_LINKS','FHIR_OP_EMPI_DUPLICATE_PERSONS','FHIR_OP_EMPI_CLEAR','FHIR_OP_EMPI_SUBMIT','FHIR_EMPI_ADMIN','FHIR_OP_EVALUATE_MEASURE','FHIR_OP_SUBMIT_DATA','FHIR_OP_CARE_GAPS','FHIR_OP_EVALUATE','FHIR_OP_COLLECTDATA','FHIR_OP_DATAREQUIREMENTS','FHIR_OP_CQL','FHIR_OP_EVALUATE_MEASURES','DQM_QPP_BUILD','FHIR_OP_APPLY','FHIR_OP_PREPOPULATE','FHIR_OP_POPULATE','FHIR_OP_EXTRACT','FHIR_OP_PACKAGE','FHIR_DTR_USER','FHIR_ALL_READ','FHIR_TRANSACTION','FHIR_GRAPHQL','FHIR_BATCH','FHIR_PATCH','FHIR_ALL_WRITE','FHIR_ALL_DELETE','FHIR_DELETE_ALL_OF_TYPE','FHIR_DELETE_ALL_IN_COMPARTMENT','FHIR_DELETE_TYPE_IN_COMPARTMENT','FHIR_DELETE_CASCADE_ALLOWED','FHIR_CAPABILITIES','FHIR_MANUAL_VALIDATION','FHIR_PROCESS_MESSAGE','FHIR_UPLOAD_EXTERNAL_TERMINOLOGY','FHIR_GET_RESOURCE_COUNTS','FHIR_TRIGGER_SUBSCRIPTION','ROLE_FHIR_TERMINOLOGY_READ_CLIENT','FHIR_OP_PATIENT_EVERYTHING','FHIR_OP_PATIENT_EVERYTHING_ACCESS_ALL','FHIR_OP_PATIENT_SUMMARY','FHIR_OP_ENCOUNTER_EVERYTHING','FHIR_OP_STRUCTUREDEFINITION_SNAPSHOT','FHIR_OP_MEMBER_MATCH','HFQL_EXECUTE','ROLE_FHIR_CLIENT_SUPERUSER_RO','ROLE_FHIR_CLIENT_SUPERUSER','ROLE_SUPERUSER','ROLE_ANONYMOUS','ETL_IMPORT_PROCESS_FILE','VIEW_CDA_TEMPLATE','CREATE_CDA_TEMPLATE','DELETE_CDA_TEMPLATE','USE_CDA_TEMPLATE','MDM_UPDATE_MATCH_RULES','MDM_VIEW_MATCH_RULES','MDM_ADMIN','FHIR_AUTO_MDM','EMPI_UPDATE_MATCH_RULES','EMPI_VIEW_MATCH_RULES','EMPI_ADMIN','PACKAGE_REGISTRY_READ','PACKAGE_REGISTRY_WRITE','INVOKE_CDS_HOOKS','AG_ADMIN_CONSOLE_READ','AG_ADMIN_CONSOLE_WRITE','AG_DEV_PORTAL_READ','AG_DEV_PORTAL_WRITE','VIEW_BATCH_JOBS','MANAGE_BATCH_JOBS','DOCREF','CDA_IMPORT','FHIR_UPDATE_REWRITE_HISTORY','SUBMIT_ATTACHMENT') not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_PHONE (
    PID bigint not null,
    COUNTRY_CODE varchar(20) not null,
    PHONE_NUMBER varchar(20) not null,
    PHONE_TYPE enum ('WORK','CELL','PERSONAL') not null,
    AG_PROFILE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_PREREQUISITE (
    PID bigint not null,
    PREREQUISITE varchar(200) not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_PROFILE (
    PID bigint not null,
    ABOUT_US varchar(250),
    ARCHIVE_DATE datetime(6),
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    LAST_MODIFIED_BY varchar(200) not null,
    LAST_MODIFIED_DATE datetime(6) not null,
    BUSINESS_NAME varchar(200),
    DESIGNATION varchar(200),
    DUNS_NUMBER varchar(200),
    FULL_NAME varchar(200) not null,
    INCORPORATED bit,
    INDIVIDUAL bit not null,
    SALES_CONTACT varchar(200),
    SUPPORT_CONTACT varchar(200),
    SUPPORT_WEBPAGE varchar(200),
    PROFILE_TYPE enum ('INDIVIDUAL','BUSINESS','PAYER'),
    WEBSITE_URL varchar(200),
    MODULE_PID bigint not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table AG_SANDBOX_CLIENT (
    PID bigint not null,
    SEED varchar(256),
    MODULE_PID bigint not null,
    OAUTH2_CLIENT_PID bigint not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table AG_SCOPE (
    PID bigint not null,
    SCOPE varchar(200) not null,
    SCOPE_TYPE enum ('REGULAR','AUTO_GRANT','AUTO_APPROVE'),
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table AG_SCREENSHOT (
    PID bigint not null,
    FILENAME varchar(200) not null,
    POSITION integer not null,
    ASSET_STATUS enum ('INREVIEW','APPROVED','DECLINED') not null,
    SCREENSHOT_PID bigint not null,
    AG_APPL_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_AUDIT_EVT (
    PID bigint not null,
    EVT_ADDITIONAL_JSON tinytext,
    EVT_ADDITIONAL_JSON_VC longtext,
    AUSER_TYPE integer,
    HAVE_HEADERS bit,
    REMOTE_ADDRESS varchar(100),
    REQUEST_ID varchar(128),
    HAVE_TARGET_MODULES bit not null,
    SOURCE_TRANSACTION_ID varchar(128),
    HAVE_TARGET_RESOURCES bit not null,
    HAVE_TARGET_USERS bit not null,
    EVT_TIMESTAMP datetime(6) not null,
    TRANSACTION_GUID varchar(36),
    TYPE_DISPLAY varchar(200) not null,
    USER_PID bigint,
    CLIENT_PID bigint,
    ENDPOINT_MODULE_PID bigint not null,
    TYPE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_AUDIT_EVT_HEADER (
    PID bigint not null,
    EVT_HEADER_NAME varchar(100) not null,
    EVT_HEADER_VALUE varchar(250),
    EVENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_AUDIT_EVT_TARGET_MODULE (
    PID bigint not null,
    EVENT_PID bigint not null,
    MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_AUDIT_EVT_TARGET_RES (
    PID bigint not null,
    REQ_VAL_RESULT integer,
    RES_ID varchar(120) not null,
    RES_VERSION bigint,
    RES_VERSION_STR varchar(128),
    EVENT_PID bigint not null,
    PERS_MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_AUDIT_EVT_TARGET_USER (
    PID bigint not null,
    USER_PID bigint not null,
    EVENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_AUDIT_EVT_TYPE (
    PID bigint not null,
    CODEVAL varchar(200),
    SYSTEM_URL varchar(200),
    primary key (PID)
) engine=InnoDB;

create table CDR_CACHE_SYNC (
    PID bigint not null,
    CACHE_ID varchar(256) not null,
    MODULE_PID bigint not null,
    UPDATED_TIME datetime(6) not null,
    VERSION bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_CDA_TEMPLATE (
    PID bigint not null,
    TEMPLATE_DESCRIPTION varchar(250),
    TEMPLATE_ID varchar(250) not null,
    TEMPLATE_CONTENT mediumtext,
    TEMPLATE_CONTENT_VC longtext,
    MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_CDA_TEMPLATE_PARAM (
    PID bigint not null,
    TEMPLATE_PARAMETER_NAME varchar(250) not null,
    TEMPLATE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_DB_VERSION (
    DB_VERSION varchar(100) not null,
    DB_INIT_TIME datetime(6) not null,
    primary key (DB_VERSION)
) engine=InnoDB;

create table CDR_GLOBAL_GAUGE (
    ID varchar(200) not null,
    VAL_DOUBLE float(53),
    VAL_LONG bigint,
    primary key (ID)
) engine=InnoDB;

create table CDR_HTTP_SESSION (
    PID bigint not null,
    SES_ATTRS tinyblob,
    SES_ATTRS_BIN longblob,
    SES_EXPIRY datetime(6) not null,
    LAST_ACCESSED_TIME datetime(6),
    MAX_INACTIVE bigint not null,
    PRINCIPAL_USERNAME varchar(200),
    SES_ID varchar(200) not null,
    MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_IDENTIFICATION_CODES (
    PID bigint not null,
    CDR_CODE varchar(6) not null,
    CODE_STATUS enum ('VOIDED','UNUSED','USED') not null,
    EXPIRES_ON datetime(6) not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_METRIC_GAUGE (
    GAUGE_TYPE integer not null,
    INTERVL integer not null,
    START_TIME datetime(6) not null,
    IS_COLLAPSED bit not null,
    GAUGE_VAL bigint not null,
    MODPROC_PID bigint not null,
    primary key (GAUGE_TYPE, INTERVL, MODPROC_PID, START_TIME)
) engine=InnoDB;

create table CDR_METRIC_HC (
    PID bigint not null,
    ERROR_STRING varchar(200),
    HEALTHCHECK_TYPE integer not null,
    IS_HEALTHY bit not null,
    HEALTHY_STRING varchar(200),
    MODPROC_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_METRIC_HEALTH (
    PID bigint not null,
    CUSTOM_HEALTHCHECK_NAME varchar(256),
    ERROR_STRING varchar(256),
    HEALTHCHECK_TYPE integer not null,
    IS_HEALTHY bit not null,
    HEALTHY_STRING varchar(256),
    MODPROC_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_METRIC_TIMER (
    INTERVL integer not null,
    START_TIME datetime(6) not null,
    TIMER_TYPE integer not null,
    IS_COLLAPSED bit not null,
    COUNT_VAL bigint,
    RATE_15_MIN float(53) not null,
    FIRST_SINCE_RS bit not null,
    RATE_5_MIN float(53) not null,
    LATENCY_MAX integer not null,
    LATENCY_MEAN integer not null,
    LATENCY_MIN integer not null,
    MODPROC_PID bigint not null,
    RATE_1_MIN float(53) not null,
    primary key (INTERVL, MODPROC_PID, START_TIME, TIMER_TYPE)
) engine=InnoDB;

create table CDR_MODULE (
    PID bigint not null,
    DELETED bit not null,
    MODULE_DISABLED bit not null,
    MATURITY integer,
    MODULE_ID varchar(50) not null,
    PORTVAL integer,
    NODE_PID bigint not null,
    PROTOTYPE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_CFG_PROP (
    PID bigint not null,
    VALUE_STRING varchar(200),
    VALUE_EXTENDED mediumtext,
    VALUE_EXTENDED_VC longtext,
    MODULE_PID bigint not null,
    PROTOTYPE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_DEP (
    PID bigint not null,
    MODULE_PID bigint not null,
    PROTOTYPE_PID bigint not null,
    TARGET_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_PROCESS (
    PID bigint not null,
    FIRST_MP bit,
    MODULE_PID bigint not null,
    NODEPROC_PID bigint not null,
    RESTART_REQUIRED bit not null,
    MODULE_STATUS integer not null,
    MODULE_STATUS_DESC varchar(200),
    STATUS_TIMESTAMP datetime(6),
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_PROT_CFG (
    PID bigint not null,
    IS_ADVANCED bit not null,
    CATEGORY_KEY varchar(100) not null,
    DEFAULT_VALUE varchar(200),
    DESC_KEY varchar(200),
    ENUM_TYPE varchar(200),
    CFG_INDEX integer not null,
    CFG_KEY varchar(200) not null,
    CFG_MATURITY enum ('STABLE','TRIAL','EXPERIMENTAL','DEPRECATED','REMOVED'),
    NAME_KEY varchar(200) not null,
    IS_OPTIONAL bit not null,
    CFG_TYPE enum ('ENUM','NON_NEGATIVE_INTEGER','BOOLEAN','STRING','POSITIVE_INTEGER','LOCAL_FILEPATH','LOCAL_FILEDIR','PASSWORD','JAVASCRIPT','JSON','STRING_MULTILINE','PROPERTIES','INTEGER') not null,
    PROTOTYPE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_PROT_DEP (
    PID bigint not null,
    DESCRIPTION_KEY varchar(200) not null,
    ENTRY_KEY enum ('CLUSTERMGR','PERSISTENCE_DSTU2','PERSISTENCE_DSTU3','PERSISTENCE_ALL','SECURITY_IN_OIC','SECURITY_IN_UP','SECURITY_IN_USERMGR','ENDPOINT_FHIR','ETL_IMPORTER','PERSISTENCE_R4','CDA_EXCHANGE','ENDPOINT_HL7V2_OUTBOUND','NARRATIVE_GENERATOR','SECURITY_IN_ANONYMOUS','SUBSCRIPTION','ENDPOINT_SUBSCRIPTION_WEBSOCKET','PACKAGE_CACHE','SECURITY_IN_SAML','VALIDATION_SUPPORT','SECURITY_USER_SELF_REGISTRATION','ENDPOINT_FHIR_SANDBOX','BOOT_AFTER','ENDPOINT_AWSHEALTHLAKE_OUTBOUND','LICENSE','MDM','ADMIN_JSON','CQL','ENDPOINT_HL7V2_IN','ENDPOINT_CDS_HOOKS','EASYSHARE_PUBLIC') not null,
    PROTOTYPE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_PROT_SUPPLIES (
    PID bigint not null,
    ENTRY_KEY integer not null,
    PROTOTYPE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_PROTOTYPE (
    PID bigint not null,
    MODULE_TYPE enum ('ADMIN_JSON','ADMIN_WEB','PERSISTENCE_DSTU2','PERSISTENCE_DSTU3','PERSISTENCE_R4','PERSISTENCE_R5','ENDPOINT_FHIR_REST','ENDPOINT_FHIR_REST_DSTU2','ENDPOINT_FHIR_REST_DSTU3','ENDPOINT_FHIR_REST_R4','ENDPOINT_FHIRWEB','ENDPOINT_HYBRID_PROVIDERS','ENDPOINT_CDS_HOOKS','ENDPOINT_FHIR_GATEWAY','ENDPOINT_PACKAGE_REGISTRY','ENDPOINT_EASYSHARE_SHL_PUBLIC','ENDPOINT_EASYSHARE_SHL_ADMIN','SECURITY_IN_LOCAL','SECURITY_IN_LDAP','SECURITY_IN_SCRIPT','SECURITY_IN_SMART','SECURITY_IN_SAML','SECURITY_OUT_SMART','ENDPOINT_HL7V2_IN','ENDPOINT_HL7V2_IN_V2','ENDPOINT_HL7V2_OUT','SMART_APPS_HOST','CLUSTER_MGR','ETL_IMPORTER','CDA_EXCHANGE','CDA_EXCHANGE_PLUS','CHANNEL_IMPORT','SUBSCRIPTION_MATCHER','SUBSCRIPTION_MATCHER_DSTU2','SUBSCRIPTION_MATCHER_DSTU3','SUBSCRIPTION_MATCHER_R4','NARRATIVE_GENERATOR','ENDPOINT_SUBSCRIPTION_WEBSOCKET','PERSISTENCE_MONGODB','EMPI','MDM','REALTIME_EXPORT','ENDPOINT_AWSHEALTHLAKE_OUT','APP_GALLERY','ENDPOINT_P2P','SYSTEM_TO_SYSTEM_DATA_EXCHANGE','ENDPOINT_MDM_UI','AUDIT_LOG_PERSISTENCE','TRANSACTION_LOG_PERSISTENCE','DQM','CQL','LICENSE','PRIOR_AUTH_DTR','CAMEL','PRIOR_AUTH_CRD','PRIOR_AUTH_PAS','TRANSACTION_LOG_BROKER') not null,
    STOPPABLE bit not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_MODULE_STATE (
    PID bigint not null,
    STATE_TYPE integer not null,
    STATE_VAL varchar(200),
    MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_NODE (
    PID bigint not null,
    IS_CONFIG_LOCKED bit,
    IS_DELETED bit,
    ENVIRONMENT_TYPE enum ('DEV','QA','PERF','STAGING','PROD'),
    NODE_ID varchar(30) not null,
    IS_SECURITY_STRICT bit,
    primary key (PID)
) engine=InnoDB;

create table CDR_NODE_MODULE_DIAGNOSTICS (
    DIAGNOSTICS_JSON tinytext,
    DIAGNOSTICS_JSON_VC longtext,
    MODULE_PID bigint not null,
    NODE_PID bigint not null,
    primary key (MODULE_PID, NODE_PID)
) engine=InnoDB;

create table CDR_NODE_PROCESS (
    PID bigint not null,
    CREATED_TIME datetime(6) not null,
    HEARTBEAT_TIME datetime(6),
    KILLED_BY varchar(20),
    NODE_PID bigint not null,
    PROCESS_ID varchar(20) not null,
    PROCESS_NAME varchar(100),
    STARTED_TIME datetime(6),
    NODE_STATUS integer not null,
    STOPPED_TIME datetime(6),
    OPT_LOCK integer not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OA2_CLI_DET_AUTH_GRNT_TYP (
    PID bigint not null,
    GRANT_TYPE enum ('AUTHORIZATION_CODE','IMPLICIT','REFRESH_TOKEN','CLIENT_CREDENTIALS','PASSWORD','JWT_BEARER') not null,
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OA2_CLI_DET_AUTOAP_SCOPE (
    PID bigint not null,
    SCOPE varchar(764) not null,
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OA2_CLI_DET_AUTOGRNT_SCOPE (
    PID bigint not null,
    SCOPE varchar(764) not null,
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OA2_CLI_DET_CLISEC (
    PID bigint not null,
    SEC_ACTIVATION datetime(6),
    SEC_CREATION datetime(6),
    SEC_DESC varchar(250),
    SEC_EXPIRATION datetime(6),
    CLI_SECRET varchar(250) not null,
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OA2_CLI_DET_REG_REDIR_URI (
    PID bigint not null,
    REDIR_URI varchar(200) not null,
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OA2_SERVER (
    PID bigint not null,
    ARCHIVED_AT datetime(6),
    AUDIENCE varchar(500),
    AUTH_WELL_KNOWN_CONFIG_URL varchar(500),
    CUSTOM_TOKEN_PARAMS varchar(500),
    FEDERATION_AUTH_SCRIPT_TEXT tinyblob,
    FEDERATION_AUTH_SCRIPT_TXT_BIN longblob,
    FEDERATION_AUTH_URL varchar(500),
    FEDERATION_JWKS_URL varchar(500),
    FEDERATION_REG_ID varchar(500) not null,
    FEDERATION_REQ_SCOPES varchar(500),
    FEDERATION_TOKEN_URL varchar(500),
    FEDERATION_USER_INFO_URL varchar(500),
    FEDERATION_USER_MAPPING_TEXT tinyblob,
    FEDERATION_USR_MAPPING_TXT_BIN longblob,
    FHIR_ENDPOINT_URL varchar(500),
    ISS varchar(200) not null,
    SERVER_NAME varchar(200),
    NOTES varchar(1000),
    ORGANIZATION_ID varchar(500),
    RESPONSE_TYPE varchar(500),
    INTRSPCT_CLIENT_ID varchar(200),
    INTRSPCT_CLIENT_SCRT varchar(200),
    JWKS_FILE varchar(500),
    JWKS_TEXT mediumtext,
    JWKS_TEXT_VC longtext,
    MODULE_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_ATOKEN (
    PID bigint not null,
    EXPIRATION datetime(6) not null,
    GRANT_TYPE enum ('AUTHORIZATION_CODE','IMPLICIT','REFRESH_TOKEN','CLIENT_CREDENTIALS','PASSWORD','JWT_BEARER'),
    ID_TOKEN_BYTES longblob,
    ID_TOKEN_BYTES_BIN longblob,
    ID_TOKEN_VAL varchar(1000),
    ISSUED datetime(6) not null,
    REDIRECT_URI varchar(200),
    TOKEN_HASH varchar(150) not null,
    TOKEN_BYTES longblob,
    TOKEN_BYTES_BIN longblob,
    TOKEN_VAL varchar(1000),
    CLIENT_PID bigint not null,
    MODULE_PID bigint not null,
    REFRESH_TOKEN_PID bigint,
    USER_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_ATOKEN_ADNLINFO (
    PID bigint not null,
    INFO_KEY varchar(200) not null,
    INFO_VALUE varchar(200) not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_ATOKEN_GRNTDA (
    PID bigint not null,
    PERM_ARG varchar(764),
    PERM_NAME enum ('CHANGE_OWN_PASSWORD','ACCESS_EASYSHARE','EASYSHARE_CREATE_SMART_HEALTH_LINK','CHANGE_OWN_DEFAULT_LAUNCH_CONTEXTS','CHANGE_OWN_TFA_KEY','ACCESS_ADMIN_WEB','ACCESS_ADMIN_JSON','ACCESS_FHIR_ENDPOINT','ACCESS_FHIRWEB','VIEW_METRICS','VIEW_MODULE_STATUS','VIEW_MODULE_CONFIG','ARCHIVE_MODULE','REINSTATE_MODULE','OPENID_CONNECT_VIEW_CLIENT_LIST','OPENID_CONNECT_VIEW_SERVER_LIST','OPENID_CONNECT_ADD_CLIENT','OIDC_CLIENT_PRESET_PERMISSION','OPENID_CONNECT_ADD_SERVER','OPENID_CONNECT_EDIT_SERVER','OPENID_CONNECT_EDIT_CLIENT','OPENID_CONNECT_MANAGE_GLOBAL_SESSIONS','CREATE_USER','UPDATE_USER','VIEW_USERS','SAVE_USER','ROLE_FHIR_CLIENT','ROLE_SYSTEM','ROLE_SYSTEM_INITIALIZATION','VIEW_AUDIT_LOG','VIEW_TRANSACTION_LOG','VIEW_TRANSACTION_LOG_EVENT','UPDATE_MODULE_CONFIG','START_STOP_MODULE','CONTROL_MODULE','CREATE_MODULE','MODULE_ADMIN','FHIR_ACCESS_PARTITION_ALL','FHIR_ACCESS_PARTITION_NAME','FHIR_OP_BINARY_ACCESS_READ','FHIR_OP_BINARY_ACCESS_WRITE','FHIR_OP_INITIATE_BULK_DATA_EXPORT','FHIR_OP_INITIATE_BULK_DATA_IMPORT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_GROUP','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_ALL_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_SYSTEM','FHIR_READ_SEARCH_PARAMETERS','FHIR_MODIFY_SEARCH_PARAMETERS','FHIR_READ_ALL_IN_COMPARTMENT','FHIR_WRITE_ALL_IN_COMPARTMENT','FHIR_READ_TYPE_IN_COMPARTMENT','FHIR_WRITE_TYPE_IN_COMPARTMENT','FHIR_READ_ALL_OF_TYPE','FHIR_WRITE_ALL_OF_TYPE','FHIR_READ_INSTANCE','FHIR_WRITE_INSTANCE','BLOCK_FHIR_READ_UNLESS_CODE_IN_VS','BLOCK_FHIR_READ_UNLESS_CODE_NOT_IN_VS','FHIR_EXPUNGE_DELETED','FHIR_EXPUNGE_PREVIOUS_VERSIONS','FHIR_EXPUNGE_EVERYTHING','FHIR_DELETE_EXPUNGE','FHIR_LIVEBUNDLE','FHIR_MANAGE_PARTITIONS','FHIR_META_OPERATIONS_SUPERUSER','FHIR_EXTENDED_OPERATION_SUPERUSER','FHIR_EXTENDED_OPERATION_ON_SERVER','FHIR_EXTENDED_OPERATION_ON_TYPE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE_OF_TYPE','FHIR_OP_PATIENT_MATCH','FHIR_OP_MDM_MERGE_GOLDEN_RESOURCES','FHIR_OP_MDM_UPDATE_LINK','FHIR_OP_MDM_CREATE_LINK','FHIR_OP_MDM_QUERY_LINKS','FHIR_OP_MDM_LINK_HISTORY','FHIR_OP_MDM_DUPLICATE_GOLDEN_RESOURCES','FHIR_OP_MDM_NOT_DUPLICATE','FHIR_OP_MDM_CLEAR','FHIR_OP_MDM_SUBMIT','FHIR_MDM_ADMIN','FHIR_OP_EMPI_MERGE_PERSONS','FHIR_OP_EMPI_UPDATE_LINK','FHIR_OP_EMPI_QUERY_LINKS','FHIR_OP_EMPI_DUPLICATE_PERSONS','FHIR_OP_EMPI_CLEAR','FHIR_OP_EMPI_SUBMIT','FHIR_EMPI_ADMIN','FHIR_OP_EVALUATE_MEASURE','FHIR_OP_SUBMIT_DATA','FHIR_OP_CARE_GAPS','FHIR_OP_EVALUATE','FHIR_OP_COLLECTDATA','FHIR_OP_DATAREQUIREMENTS','FHIR_OP_CQL','FHIR_OP_EVALUATE_MEASURES','DQM_QPP_BUILD','FHIR_OP_APPLY','FHIR_OP_PREPOPULATE','FHIR_OP_POPULATE','FHIR_OP_EXTRACT','FHIR_OP_PACKAGE','FHIR_DTR_USER','FHIR_ALL_READ','FHIR_TRANSACTION','FHIR_GRAPHQL','FHIR_BATCH','FHIR_PATCH','FHIR_ALL_WRITE','FHIR_ALL_DELETE','FHIR_DELETE_ALL_OF_TYPE','FHIR_DELETE_ALL_IN_COMPARTMENT','FHIR_DELETE_TYPE_IN_COMPARTMENT','FHIR_DELETE_CASCADE_ALLOWED','FHIR_CAPABILITIES','FHIR_MANUAL_VALIDATION','FHIR_PROCESS_MESSAGE','FHIR_UPLOAD_EXTERNAL_TERMINOLOGY','FHIR_GET_RESOURCE_COUNTS','FHIR_TRIGGER_SUBSCRIPTION','ROLE_FHIR_TERMINOLOGY_READ_CLIENT','FHIR_OP_PATIENT_EVERYTHING','FHIR_OP_PATIENT_EVERYTHING_ACCESS_ALL','FHIR_OP_PATIENT_SUMMARY','FHIR_OP_ENCOUNTER_EVERYTHING','FHIR_OP_STRUCTUREDEFINITION_SNAPSHOT','FHIR_OP_MEMBER_MATCH','HFQL_EXECUTE','ROLE_FHIR_CLIENT_SUPERUSER_RO','ROLE_FHIR_CLIENT_SUPERUSER','ROLE_SUPERUSER','ROLE_ANONYMOUS','ETL_IMPORT_PROCESS_FILE','VIEW_CDA_TEMPLATE','CREATE_CDA_TEMPLATE','DELETE_CDA_TEMPLATE','USE_CDA_TEMPLATE','MDM_UPDATE_MATCH_RULES','MDM_VIEW_MATCH_RULES','MDM_ADMIN','FHIR_AUTO_MDM','EMPI_UPDATE_MATCH_RULES','EMPI_VIEW_MATCH_RULES','EMPI_ADMIN','PACKAGE_REGISTRY_READ','PACKAGE_REGISTRY_WRITE','INVOKE_CDS_HOOKS','AG_ADMIN_CONSOLE_READ','AG_ADMIN_CONSOLE_WRITE','AG_DEV_PORTAL_READ','AG_DEV_PORTAL_WRITE','VIEW_BATCH_JOBS','MANAGE_BATCH_JOBS','DOCREF','CDA_IMPORT','FHIR_UPDATE_REWRITE_HISTORY','SUBMIT_ATTACHMENT') not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_ATOKEN_SCOPE (
    PID bigint not null,
    SCOPE varchar(764) not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_ATOKEN_UDATA (
    ATOKEN_PID bigint not null,
    TOKEN_KEY varchar(256) not null,
    VAL tinyblob,
    primary key (ATOKEN_PID, TOKEN_KEY)
) engine=InnoDB;

create table CDR_OAUTH2_ATOKEN_UDATA_BIN (
    ATOKEN_PID bigint not null,
    TOKEN_KEY varchar(256) not null,
    VAL_BIN longblob,
    primary key (ATOKEN_PID, TOKEN_KEY)
) engine=InnoDB;

create table CDR_OAUTH2_AUTH_CODE (
    PID bigint not null,
    OAUTH2_AUTHENTICATION tinyblob,
    OAUTH2_AUTHENTICATION_BIN longblob,
    CLIENT_ID varchar(200) not null,
    CODE_VAL varchar(100) not null,
    EXPIRATION datetime(6) not null,
    PKCE_CHALLENGE varchar(200),
    PKCE_CHALLENGE_TYPE enum ('PLAIN','S256'),
    STATE_VAL varchar(256),
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_CLIENT_DET_SCOPE (
    PID bigint not null,
    SCOPE varchar(764) not null,
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_CLIENT_DETAILS (
    PID bigint not null,
    ACCESS_TOKEN_VALIDITY_SECONDS integer,
    ALWAYS_REQUIRE_APPROVAL bit,
    ARCHIVED_AT datetime(6),
    ATTESTATION_ACCEPTED bit,
    CAN_INTROSPECT_ANY bit,
    CAN_INTROSPECT_OWN bit,
    CAN_REUSE_TOKENS bit,
    CLIENT_ID varchar(200) not null,
    CLIENT_NAME varchar(200),
    CLIENT_SECRET varchar(200),
    ENABLED bit,
    FIXED_SCOPE bit not null,
    JWKS_URL varchar(4000),
    PUBLIC_JWKS tinyblob,
    PUBLIC_JWKS_BIN longblob,
    REFRESH_TOKEN_VALIDITY_SECONDS integer,
    REMEMBER_APPROVED_SCOPES bit,
    SECRET_CLIENT_CAN_CHANGE bit,
    SECRET_REQUIRED bit not null,
    MODULE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_CLIENT_PERM (
    PID bigint not null,
    PERMISSION_TYPE enum ('CHANGE_OWN_PASSWORD','ACCESS_EASYSHARE','EASYSHARE_CREATE_SMART_HEALTH_LINK','CHANGE_OWN_DEFAULT_LAUNCH_CONTEXTS','CHANGE_OWN_TFA_KEY','ACCESS_ADMIN_WEB','ACCESS_ADMIN_JSON','ACCESS_FHIR_ENDPOINT','ACCESS_FHIRWEB','VIEW_METRICS','VIEW_MODULE_STATUS','VIEW_MODULE_CONFIG','ARCHIVE_MODULE','REINSTATE_MODULE','OPENID_CONNECT_VIEW_CLIENT_LIST','OPENID_CONNECT_VIEW_SERVER_LIST','OPENID_CONNECT_ADD_CLIENT','OIDC_CLIENT_PRESET_PERMISSION','OPENID_CONNECT_ADD_SERVER','OPENID_CONNECT_EDIT_SERVER','OPENID_CONNECT_EDIT_CLIENT','OPENID_CONNECT_MANAGE_GLOBAL_SESSIONS','CREATE_USER','UPDATE_USER','VIEW_USERS','SAVE_USER','ROLE_FHIR_CLIENT','ROLE_SYSTEM','ROLE_SYSTEM_INITIALIZATION','VIEW_AUDIT_LOG','VIEW_TRANSACTION_LOG','VIEW_TRANSACTION_LOG_EVENT','UPDATE_MODULE_CONFIG','START_STOP_MODULE','CONTROL_MODULE','CREATE_MODULE','MODULE_ADMIN','FHIR_ACCESS_PARTITION_ALL','FHIR_ACCESS_PARTITION_NAME','FHIR_OP_BINARY_ACCESS_READ','FHIR_OP_BINARY_ACCESS_WRITE','FHIR_OP_INITIATE_BULK_DATA_EXPORT','FHIR_OP_INITIATE_BULK_DATA_IMPORT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_GROUP','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_ALL_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_SYSTEM','FHIR_READ_SEARCH_PARAMETERS','FHIR_MODIFY_SEARCH_PARAMETERS','FHIR_READ_ALL_IN_COMPARTMENT','FHIR_WRITE_ALL_IN_COMPARTMENT','FHIR_READ_TYPE_IN_COMPARTMENT','FHIR_WRITE_TYPE_IN_COMPARTMENT','FHIR_READ_ALL_OF_TYPE','FHIR_WRITE_ALL_OF_TYPE','FHIR_READ_INSTANCE','FHIR_WRITE_INSTANCE','BLOCK_FHIR_READ_UNLESS_CODE_IN_VS','BLOCK_FHIR_READ_UNLESS_CODE_NOT_IN_VS','FHIR_EXPUNGE_DELETED','FHIR_EXPUNGE_PREVIOUS_VERSIONS','FHIR_EXPUNGE_EVERYTHING','FHIR_DELETE_EXPUNGE','FHIR_LIVEBUNDLE','FHIR_MANAGE_PARTITIONS','FHIR_META_OPERATIONS_SUPERUSER','FHIR_EXTENDED_OPERATION_SUPERUSER','FHIR_EXTENDED_OPERATION_ON_SERVER','FHIR_EXTENDED_OPERATION_ON_TYPE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE_OF_TYPE','FHIR_OP_PATIENT_MATCH','FHIR_OP_MDM_MERGE_GOLDEN_RESOURCES','FHIR_OP_MDM_UPDATE_LINK','FHIR_OP_MDM_CREATE_LINK','FHIR_OP_MDM_QUERY_LINKS','FHIR_OP_MDM_LINK_HISTORY','FHIR_OP_MDM_DUPLICATE_GOLDEN_RESOURCES','FHIR_OP_MDM_NOT_DUPLICATE','FHIR_OP_MDM_CLEAR','FHIR_OP_MDM_SUBMIT','FHIR_MDM_ADMIN','FHIR_OP_EMPI_MERGE_PERSONS','FHIR_OP_EMPI_UPDATE_LINK','FHIR_OP_EMPI_QUERY_LINKS','FHIR_OP_EMPI_DUPLICATE_PERSONS','FHIR_OP_EMPI_CLEAR','FHIR_OP_EMPI_SUBMIT','FHIR_EMPI_ADMIN','FHIR_OP_EVALUATE_MEASURE','FHIR_OP_SUBMIT_DATA','FHIR_OP_CARE_GAPS','FHIR_OP_EVALUATE','FHIR_OP_COLLECTDATA','FHIR_OP_DATAREQUIREMENTS','FHIR_OP_CQL','FHIR_OP_EVALUATE_MEASURES','DQM_QPP_BUILD','FHIR_OP_APPLY','FHIR_OP_PREPOPULATE','FHIR_OP_POPULATE','FHIR_OP_EXTRACT','FHIR_OP_PACKAGE','FHIR_DTR_USER','FHIR_ALL_READ','FHIR_TRANSACTION','FHIR_GRAPHQL','FHIR_BATCH','FHIR_PATCH','FHIR_ALL_WRITE','FHIR_ALL_DELETE','FHIR_DELETE_ALL_OF_TYPE','FHIR_DELETE_ALL_IN_COMPARTMENT','FHIR_DELETE_TYPE_IN_COMPARTMENT','FHIR_DELETE_CASCADE_ALLOWED','FHIR_CAPABILITIES','FHIR_MANUAL_VALIDATION','FHIR_PROCESS_MESSAGE','FHIR_UPLOAD_EXTERNAL_TERMINOLOGY','FHIR_GET_RESOURCE_COUNTS','FHIR_TRIGGER_SUBSCRIPTION','ROLE_FHIR_TERMINOLOGY_READ_CLIENT','FHIR_OP_PATIENT_EVERYTHING','FHIR_OP_PATIENT_EVERYTHING_ACCESS_ALL','FHIR_OP_PATIENT_SUMMARY','FHIR_OP_ENCOUNTER_EVERYTHING','FHIR_OP_STRUCTUREDEFINITION_SNAPSHOT','FHIR_OP_MEMBER_MATCH','HFQL_EXECUTE','ROLE_FHIR_CLIENT_SUPERUSER_RO','ROLE_FHIR_CLIENT_SUPERUSER','ROLE_SUPERUSER','ROLE_ANONYMOUS','ETL_IMPORT_PROCESS_FILE','VIEW_CDA_TEMPLATE','CREATE_CDA_TEMPLATE','DELETE_CDA_TEMPLATE','USE_CDA_TEMPLATE','MDM_UPDATE_MATCH_RULES','MDM_VIEW_MATCH_RULES','MDM_ADMIN','FHIR_AUTO_MDM','EMPI_UPDATE_MATCH_RULES','EMPI_VIEW_MATCH_RULES','EMPI_ADMIN','PACKAGE_REGISTRY_READ','PACKAGE_REGISTRY_WRITE','INVOKE_CDS_HOOKS','AG_ADMIN_CONSOLE_READ','AG_ADMIN_CONSOLE_WRITE','AG_DEV_PORTAL_READ','AG_DEV_PORTAL_WRITE','VIEW_BATCH_JOBS','MANAGE_BATCH_JOBS','DOCREF','CDA_IMPORT','FHIR_UPDATE_REWRITE_HISTORY','SUBMIT_ATTACHMENT') not null,
    PERMISSION_ARG varchar(200),
    CLIENT_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_JWT_UNIQ_ID (
    JWT_ID varchar(500) not null,
    CONSUMED_TIMESTAMP datetime(6) not null,
    primary key (JWT_ID)
) engine=InnoDB;

create table CDR_OAUTH2_KEYSTORE (
    KEYSTORE_ID varchar(50) not null,
    FILE_PATH varchar(4000),
    JSON_KEYS varchar(4000),
    primary key (KEYSTORE_ID)
) engine=InnoDB;

create table CDR_OAUTH2_REFRESH_TOKEN (
    PID bigint not null,
    EXPIRATION datetime(6),
    ISSUED datetime(6) not null,
    TOKEN_VAL varchar(150) not null,
    CLIENT_PID bigint,
    USER_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_ADNLINFO (
    PID bigint not null,
    INFO_KEY varchar(200) not null,
    INFO_VALUE varchar(200) not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_GRNTDA (
    PID bigint not null,
    PERM_ARG varchar(764),
    PERM_NAME enum ('CHANGE_OWN_PASSWORD','ACCESS_EASYSHARE','EASYSHARE_CREATE_SMART_HEALTH_LINK','CHANGE_OWN_DEFAULT_LAUNCH_CONTEXTS','CHANGE_OWN_TFA_KEY','ACCESS_ADMIN_WEB','ACCESS_ADMIN_JSON','ACCESS_FHIR_ENDPOINT','ACCESS_FHIRWEB','VIEW_METRICS','VIEW_MODULE_STATUS','VIEW_MODULE_CONFIG','ARCHIVE_MODULE','REINSTATE_MODULE','OPENID_CONNECT_VIEW_CLIENT_LIST','OPENID_CONNECT_VIEW_SERVER_LIST','OPENID_CONNECT_ADD_CLIENT','OIDC_CLIENT_PRESET_PERMISSION','OPENID_CONNECT_ADD_SERVER','OPENID_CONNECT_EDIT_SERVER','OPENID_CONNECT_EDIT_CLIENT','OPENID_CONNECT_MANAGE_GLOBAL_SESSIONS','CREATE_USER','UPDATE_USER','VIEW_USERS','SAVE_USER','ROLE_FHIR_CLIENT','ROLE_SYSTEM','ROLE_SYSTEM_INITIALIZATION','VIEW_AUDIT_LOG','VIEW_TRANSACTION_LOG','VIEW_TRANSACTION_LOG_EVENT','UPDATE_MODULE_CONFIG','START_STOP_MODULE','CONTROL_MODULE','CREATE_MODULE','MODULE_ADMIN','FHIR_ACCESS_PARTITION_ALL','FHIR_ACCESS_PARTITION_NAME','FHIR_OP_BINARY_ACCESS_READ','FHIR_OP_BINARY_ACCESS_WRITE','FHIR_OP_INITIATE_BULK_DATA_EXPORT','FHIR_OP_INITIATE_BULK_DATA_IMPORT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_GROUP','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_ALL_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_SYSTEM','FHIR_READ_SEARCH_PARAMETERS','FHIR_MODIFY_SEARCH_PARAMETERS','FHIR_READ_ALL_IN_COMPARTMENT','FHIR_WRITE_ALL_IN_COMPARTMENT','FHIR_READ_TYPE_IN_COMPARTMENT','FHIR_WRITE_TYPE_IN_COMPARTMENT','FHIR_READ_ALL_OF_TYPE','FHIR_WRITE_ALL_OF_TYPE','FHIR_READ_INSTANCE','FHIR_WRITE_INSTANCE','BLOCK_FHIR_READ_UNLESS_CODE_IN_VS','BLOCK_FHIR_READ_UNLESS_CODE_NOT_IN_VS','FHIR_EXPUNGE_DELETED','FHIR_EXPUNGE_PREVIOUS_VERSIONS','FHIR_EXPUNGE_EVERYTHING','FHIR_DELETE_EXPUNGE','FHIR_LIVEBUNDLE','FHIR_MANAGE_PARTITIONS','FHIR_META_OPERATIONS_SUPERUSER','FHIR_EXTENDED_OPERATION_SUPERUSER','FHIR_EXTENDED_OPERATION_ON_SERVER','FHIR_EXTENDED_OPERATION_ON_TYPE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE_OF_TYPE','FHIR_OP_PATIENT_MATCH','FHIR_OP_MDM_MERGE_GOLDEN_RESOURCES','FHIR_OP_MDM_UPDATE_LINK','FHIR_OP_MDM_CREATE_LINK','FHIR_OP_MDM_QUERY_LINKS','FHIR_OP_MDM_LINK_HISTORY','FHIR_OP_MDM_DUPLICATE_GOLDEN_RESOURCES','FHIR_OP_MDM_NOT_DUPLICATE','FHIR_OP_MDM_CLEAR','FHIR_OP_MDM_SUBMIT','FHIR_MDM_ADMIN','FHIR_OP_EMPI_MERGE_PERSONS','FHIR_OP_EMPI_UPDATE_LINK','FHIR_OP_EMPI_QUERY_LINKS','FHIR_OP_EMPI_DUPLICATE_PERSONS','FHIR_OP_EMPI_CLEAR','FHIR_OP_EMPI_SUBMIT','FHIR_EMPI_ADMIN','FHIR_OP_EVALUATE_MEASURE','FHIR_OP_SUBMIT_DATA','FHIR_OP_CARE_GAPS','FHIR_OP_EVALUATE','FHIR_OP_COLLECTDATA','FHIR_OP_DATAREQUIREMENTS','FHIR_OP_CQL','FHIR_OP_EVALUATE_MEASURES','DQM_QPP_BUILD','FHIR_OP_APPLY','FHIR_OP_PREPOPULATE','FHIR_OP_POPULATE','FHIR_OP_EXTRACT','FHIR_OP_PACKAGE','FHIR_DTR_USER','FHIR_ALL_READ','FHIR_TRANSACTION','FHIR_GRAPHQL','FHIR_BATCH','FHIR_PATCH','FHIR_ALL_WRITE','FHIR_ALL_DELETE','FHIR_DELETE_ALL_OF_TYPE','FHIR_DELETE_ALL_IN_COMPARTMENT','FHIR_DELETE_TYPE_IN_COMPARTMENT','FHIR_DELETE_CASCADE_ALLOWED','FHIR_CAPABILITIES','FHIR_MANUAL_VALIDATION','FHIR_PROCESS_MESSAGE','FHIR_UPLOAD_EXTERNAL_TERMINOLOGY','FHIR_GET_RESOURCE_COUNTS','FHIR_TRIGGER_SUBSCRIPTION','ROLE_FHIR_TERMINOLOGY_READ_CLIENT','FHIR_OP_PATIENT_EVERYTHING','FHIR_OP_PATIENT_EVERYTHING_ACCESS_ALL','FHIR_OP_PATIENT_SUMMARY','FHIR_OP_ENCOUNTER_EVERYTHING','FHIR_OP_STRUCTUREDEFINITION_SNAPSHOT','FHIR_OP_MEMBER_MATCH','HFQL_EXECUTE','ROLE_FHIR_CLIENT_SUPERUSER_RO','ROLE_FHIR_CLIENT_SUPERUSER','ROLE_SUPERUSER','ROLE_ANONYMOUS','ETL_IMPORT_PROCESS_FILE','VIEW_CDA_TEMPLATE','CREATE_CDA_TEMPLATE','DELETE_CDA_TEMPLATE','USE_CDA_TEMPLATE','MDM_UPDATE_MATCH_RULES','MDM_VIEW_MATCH_RULES','MDM_ADMIN','FHIR_AUTO_MDM','EMPI_UPDATE_MATCH_RULES','EMPI_VIEW_MATCH_RULES','EMPI_ADMIN','PACKAGE_REGISTRY_READ','PACKAGE_REGISTRY_WRITE','INVOKE_CDS_HOOKS','AG_ADMIN_CONSOLE_READ','AG_ADMIN_CONSOLE_WRITE','AG_DEV_PORTAL_READ','AG_DEV_PORTAL_WRITE','VIEW_BATCH_JOBS','MANAGE_BATCH_JOBS','DOCREF','CDA_IMPORT','FHIR_UPDATE_REWRITE_HISTORY','SUBMIT_ATTACHMENT') not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_LNCHRESID (
    PID bigint not null,
    RESOURCE_ID varchar(64) not null,
    RESOURCE_TYPE varchar(50) not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_REQPRM (
    PID bigint not null,
    PARM_KEY varchar(200) not null,
    PARM_VALUE varchar(1600),
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_SCOPE (
    PID bigint not null,
    SCOPE varchar(764) not null,
    TOKEN_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_UDATA (
    TOKEN_PID bigint not null,
    TOKEN_KEY varchar(256) not null,
    VAL tinyblob,
    primary key (TOKEN_PID, TOKEN_KEY)
) engine=InnoDB;

create table CDR_OAUTH2_RTOKEN_UDATA_BIN (
    TOKEN_PID bigint not null,
    TOKEN_KEY varchar(256) not null,
    VAL_BIN longblob,
    primary key (TOKEN_PID, TOKEN_KEY)
) engine=InnoDB;

create table CDR_RESTORE (
    PID bigint not null,
    CONFIGS tinytext,
    CONFIGS_VC longtext,
    CREATED datetime(6) not null,
    VERSION varchar(50) not null,
    NODE_PID bigint not null,
    USER_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_DETAILS (
    PID bigint not null,
    IS_ANON_ACCT bit,
    CREDS_EXPIRE_ON datetime(6),
    USER_DISABLED bit not null,
    EMAIL varchar(200),
    EXPIRES_ON datetime(6),
    IS_EXTERNAL bit,
    FAILED_LOGIN_ATTEMPTS integer,
    FAMILY_NAME varchar(200),
    GIVEN_NAME varchar(200),
    LAST_ACTIVE datetime(6),
    LAST_CONNECTED datetime(6),
    USER_LOCKED bit not null,
    MODULE_PID bigint not null,
    NOTES tinytext,
    NOTES_VC longtext,
    USER_PASSWORD varchar(200),
    IS_SERVICE_ACCT bit,
    IS_SYSTEM_USER bit not null,
    UPDATED_TS datetime(6) not null,
    USERNAME varchar(200) not null,
    USERNAME_HAS_NAMESPACE bit,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_DETAILS_DEF_LNCH_CTX (
    PID bigint not null,
    CONTEXT_TYPE varchar(50) not null,
    RESOURCE_ID varchar(64) not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_DETAILS_OA2CLNAPRVSCP (
    PID bigint not null,
    IS_APPROVED bit not null,
    SCOPE varchar(100) not null,
    CLIENT_PID bigint not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_OA2CLN_TOS (
    PID bigint not null,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    REVOKED_BY varchar(200),
    REVOKED_DATE datetime(6),
    VERSION varchar(200) not null,
    CLIENT_PID bigint not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_PERM (
    PID bigint not null,
    PERMISSION_TYPE enum ('CHANGE_OWN_PASSWORD','ACCESS_EASYSHARE','EASYSHARE_CREATE_SMART_HEALTH_LINK','CHANGE_OWN_DEFAULT_LAUNCH_CONTEXTS','CHANGE_OWN_TFA_KEY','ACCESS_ADMIN_WEB','ACCESS_ADMIN_JSON','ACCESS_FHIR_ENDPOINT','ACCESS_FHIRWEB','VIEW_METRICS','VIEW_MODULE_STATUS','VIEW_MODULE_CONFIG','ARCHIVE_MODULE','REINSTATE_MODULE','OPENID_CONNECT_VIEW_CLIENT_LIST','OPENID_CONNECT_VIEW_SERVER_LIST','OPENID_CONNECT_ADD_CLIENT','OIDC_CLIENT_PRESET_PERMISSION','OPENID_CONNECT_ADD_SERVER','OPENID_CONNECT_EDIT_SERVER','OPENID_CONNECT_EDIT_CLIENT','OPENID_CONNECT_MANAGE_GLOBAL_SESSIONS','CREATE_USER','UPDATE_USER','VIEW_USERS','SAVE_USER','ROLE_FHIR_CLIENT','ROLE_SYSTEM','ROLE_SYSTEM_INITIALIZATION','VIEW_AUDIT_LOG','VIEW_TRANSACTION_LOG','VIEW_TRANSACTION_LOG_EVENT','UPDATE_MODULE_CONFIG','START_STOP_MODULE','CONTROL_MODULE','CREATE_MODULE','MODULE_ADMIN','FHIR_ACCESS_PARTITION_ALL','FHIR_ACCESS_PARTITION_NAME','FHIR_OP_BINARY_ACCESS_READ','FHIR_OP_BINARY_ACCESS_WRITE','FHIR_OP_INITIATE_BULK_DATA_EXPORT','FHIR_OP_INITIATE_BULK_DATA_IMPORT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_GROUP','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENT','FHIR_OP_INITIATE_BULK_DATA_EXPORT_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_ALL_PATIENTS','FHIR_OP_INITIATE_BULK_DATA_EXPORT_SYSTEM','FHIR_READ_SEARCH_PARAMETERS','FHIR_MODIFY_SEARCH_PARAMETERS','FHIR_READ_ALL_IN_COMPARTMENT','FHIR_WRITE_ALL_IN_COMPARTMENT','FHIR_READ_TYPE_IN_COMPARTMENT','FHIR_WRITE_TYPE_IN_COMPARTMENT','FHIR_READ_ALL_OF_TYPE','FHIR_WRITE_ALL_OF_TYPE','FHIR_READ_INSTANCE','FHIR_WRITE_INSTANCE','BLOCK_FHIR_READ_UNLESS_CODE_IN_VS','BLOCK_FHIR_READ_UNLESS_CODE_NOT_IN_VS','FHIR_EXPUNGE_DELETED','FHIR_EXPUNGE_PREVIOUS_VERSIONS','FHIR_EXPUNGE_EVERYTHING','FHIR_DELETE_EXPUNGE','FHIR_LIVEBUNDLE','FHIR_MANAGE_PARTITIONS','FHIR_META_OPERATIONS_SUPERUSER','FHIR_EXTENDED_OPERATION_SUPERUSER','FHIR_EXTENDED_OPERATION_ON_SERVER','FHIR_EXTENDED_OPERATION_ON_TYPE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE','FHIR_EXTENDED_OPERATION_ON_ANY_INSTANCE_OF_TYPE','FHIR_OP_PATIENT_MATCH','FHIR_OP_MDM_MERGE_GOLDEN_RESOURCES','FHIR_OP_MDM_UPDATE_LINK','FHIR_OP_MDM_CREATE_LINK','FHIR_OP_MDM_QUERY_LINKS','FHIR_OP_MDM_LINK_HISTORY','FHIR_OP_MDM_DUPLICATE_GOLDEN_RESOURCES','FHIR_OP_MDM_NOT_DUPLICATE','FHIR_OP_MDM_CLEAR','FHIR_OP_MDM_SUBMIT','FHIR_MDM_ADMIN','FHIR_OP_EMPI_MERGE_PERSONS','FHIR_OP_EMPI_UPDATE_LINK','FHIR_OP_EMPI_QUERY_LINKS','FHIR_OP_EMPI_DUPLICATE_PERSONS','FHIR_OP_EMPI_CLEAR','FHIR_OP_EMPI_SUBMIT','FHIR_EMPI_ADMIN','FHIR_OP_EVALUATE_MEASURE','FHIR_OP_SUBMIT_DATA','FHIR_OP_CARE_GAPS','FHIR_OP_EVALUATE','FHIR_OP_COLLECTDATA','FHIR_OP_DATAREQUIREMENTS','FHIR_OP_CQL','FHIR_OP_EVALUATE_MEASURES','DQM_QPP_BUILD','FHIR_OP_APPLY','FHIR_OP_PREPOPULATE','FHIR_OP_POPULATE','FHIR_OP_EXTRACT','FHIR_OP_PACKAGE','FHIR_DTR_USER','FHIR_ALL_READ','FHIR_TRANSACTION','FHIR_GRAPHQL','FHIR_BATCH','FHIR_PATCH','FHIR_ALL_WRITE','FHIR_ALL_DELETE','FHIR_DELETE_ALL_OF_TYPE','FHIR_DELETE_ALL_IN_COMPARTMENT','FHIR_DELETE_TYPE_IN_COMPARTMENT','FHIR_DELETE_CASCADE_ALLOWED','FHIR_CAPABILITIES','FHIR_MANUAL_VALIDATION','FHIR_PROCESS_MESSAGE','FHIR_UPLOAD_EXTERNAL_TERMINOLOGY','FHIR_GET_RESOURCE_COUNTS','FHIR_TRIGGER_SUBSCRIPTION','ROLE_FHIR_TERMINOLOGY_READ_CLIENT','FHIR_OP_PATIENT_EVERYTHING','FHIR_OP_PATIENT_EVERYTHING_ACCESS_ALL','FHIR_OP_PATIENT_SUMMARY','FHIR_OP_ENCOUNTER_EVERYTHING','FHIR_OP_STRUCTUREDEFINITION_SNAPSHOT','FHIR_OP_MEMBER_MATCH','HFQL_EXECUTE','ROLE_FHIR_CLIENT_SUPERUSER_RO','ROLE_FHIR_CLIENT_SUPERUSER','ROLE_SUPERUSER','ROLE_ANONYMOUS','ETL_IMPORT_PROCESS_FILE','VIEW_CDA_TEMPLATE','CREATE_CDA_TEMPLATE','DELETE_CDA_TEMPLATE','USE_CDA_TEMPLATE','MDM_UPDATE_MATCH_RULES','MDM_VIEW_MATCH_RULES','MDM_ADMIN','FHIR_AUTO_MDM','EMPI_UPDATE_MATCH_RULES','EMPI_VIEW_MATCH_RULES','EMPI_ADMIN','PACKAGE_REGISTRY_READ','PACKAGE_REGISTRY_WRITE','INVOKE_CDS_HOOKS','AG_ADMIN_CONSOLE_READ','AG_ADMIN_CONSOLE_WRITE','AG_DEV_PORTAL_READ','AG_DEV_PORTAL_WRITE','VIEW_BATCH_JOBS','MANAGE_BATCH_JOBS','DOCREF','CDA_IMPORT','FHIR_UPDATE_REWRITE_HISTORY','SUBMIT_ATTACHMENT') not null,
    PERMISSION_ARG varchar(200),
    USER_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_PSN (
    PID bigint not null,
    CREATED_BY varchar(200) not null,
    CREATED_DATE datetime(6) not null,
    REVOKED_BY varchar(200),
    REVOKED_DATE datetime(6),
    USER_PID bigint not null,
    VERSION varchar(200) not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_USER_TFA_KEY (
    PID bigint not null,
    CONFIRMED_AT datetime(6),
    KEY_EXPIRES datetime(6),
    FAILED_VERIFS integer,
    A_KEY varchar(250) not null,
    A_STYLE enum ('TOTP') not null,
    OPTLOCK integer not null,
    USER_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDR_XACT_LOG (
    PID bigint not null,
    ADDITIONAL_JSON longtext,
    INITIAL_TIMESTAMP datetime(6) not null,
    EVT_OUTCOME integer not null,
    SRC_XACT_ID varchar(128),
    EVT_SUBTYPE integer not null,
    SRC_GUID varchar(36),
    EVT_TYPE integer not null,
    USER_PID bigint,
    CLIENT_PID bigint,
    CDR_ENDPOINT_MODULE_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table CDR_XACT_LOG_STEP (
    STEP_PID bigint not null,
    BODY_BYTES longblob,
    BODY_BYTES_BIN longblob,
    BODY_TYPE integer,
    LOCAL_HOST varchar(100),
    LOCAL_PORT integer,
    EVT_OUTCOME integer,
    PROCESSING_TIME bigint,
    REMOTE_HOST varchar(100),
    REMOTE_PORT integer,
    REQUEST_URL_STR varchar(250),
    REQ_VAL_RESULT integer,
    REQUEST_VERB varchar(7),
    RESPONSE_STATUS smallint,
    SUBSCRIPTION_ID varchar(77),
    LOG_TIMESTAMP datetime(6) not null,
    STEP_TYPE integer not null,
    LOG_PID bigint not null,
    primary key (STEP_PID)
) engine=InnoDB;

create table SEQ_AG_ADDRESS_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_ADDRESS_PID values ( 1 );

create table SEQ_AG_APP_REQUEST_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_APP_REQUEST_PID values ( 1 );

create table SEQ_AG_APPL_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_APPL_PID values ( 1 );

create table SEQ_AG_ATTESTATION_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_ATTESTATION_PID values ( 1 );

create table SEQ_AG_CLASS_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_CLASS_PID values ( 1 );

create table SEQ_AG_COUNTRY_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_COUNTRY_PID values ( 1 );

create table SEQ_AG_DATA_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_DATA_PID values ( 1 );

create table SEQ_AG_DOCUMENT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_DOCUMENT_PID values ( 1 );

create table SEQ_AG_DRAFT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_DRAFT_PID values ( 1 );

create table SEQ_AG_MEMBER_PHONE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_MEMBER_PHONE_PID values ( 1 );

create table SEQ_AG_METADATA_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_METADATA_PID values ( 1 );

create table SEQ_AG_NOTE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_NOTE_PID values ( 1 );

create table SEQ_AG_OAUTH_REDIRECT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_OAUTH_REDIRECT_PID values ( 1 );

create table SEQ_AG_PERMISSION_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_PERMISSION_PID values ( 1 );

create table SEQ_AG_PHONE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_PHONE_PID values ( 1 );

create table SEQ_AG_PREREQUISITE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_PREREQUISITE_PID values ( 1 );

create table SEQ_AG_PROFILE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_PROFILE_PID values ( 1 );

create table SEQ_AG_SANDBOX_CLIENT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_SANDBOX_CLIENT_PID values ( 1 );

create table SEQ_AG_SCOPE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_SCOPE_PID values ( 1 );

create table SEQ_AG_SCREENSHOT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AG_SCREENSHOT_PID values ( 1 );

create table SEQ_AUDITEVT_HEADER_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AUDITEVT_HEADER_PID values ( 1 );

create table SEQ_AUDITEVT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AUDITEVT_PID values ( 1 );

create table SEQ_AUDITEVT_TARGETMODULE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AUDITEVT_TARGETMODULE_PID values ( 1 );

create table SEQ_AUDITEVT_TARGETRES_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AUDITEVT_TARGETRES_PID values ( 1 );

create table SEQ_AUDITEVT_TARGETUSER_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AUDITEVT_TARGETUSER_PID values ( 1 );

create table SEQ_AUDITEVT_TYPE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_AUDITEVT_TYPE_PID values ( 1 );

create table SEQ_CACHE_SYNC_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CACHE_SYNC_PID values ( 1 );

create table SEQ_CDATEMPLATE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDATEMPLATE_PID values ( 1 );

create table SEQ_CDATEMPLATEPARAM_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDATEMPLATEPARAM_PID values ( 1 );

create table SEQ_CDR_RESTORE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDR_RESTORE_PID values ( 1 );

create table SEQ_HTTPSESSION_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_HTTPSESSION_PID values ( 1 );

create table SEQ_ID_CODE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_ID_CODE_PID values ( 1 );

create table SEQ_METRICHC_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_METRICHC_PID values ( 1 );

create table SEQ_METRICHEALTH_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_METRICHEALTH_PID values ( 1 );

create table SEQ_MODPROC_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODPROC_PID values ( 1 );

create table SEQ_MODSTAT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODSTAT_PID values ( 1 );

create table SEQ_MODULE_CFGPROP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_CFGPROP_PID values ( 1 );

create table SEQ_MODULE_DEP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_DEP_PID values ( 1 );

create table SEQ_MODULE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_PID values ( 1 );

create table SEQ_MODULE_PROT_CFG_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_PROT_CFG_PID values ( 1 );

create table SEQ_MODULE_PROT_DEP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_PROT_DEP_PID values ( 1 );

create table SEQ_MODULE_PROT_SUPPLIES_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_PROT_SUPPLIES_PID values ( 1 );

create table SEQ_MODULE_PROTOTYPE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_MODULE_PROTOTYPE_PID values ( 1 );

create table SEQ_NODE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_NODE_PID values ( 1 );

create table SEQ_NODEPROC_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_NODEPROC_PID values ( 1 );

create table SEQ_OA2ATOKADNLINFO_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2ATOKADNLINFO_PID values ( 1 );

create table SEQ_OA2ATOKEN_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2ATOKEN_PID values ( 1 );

create table SEQ_OA2ATOKGRNTDA_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2ATOKGRNTDA_PID values ( 1 );

create table SEQ_OA2ATOKSCP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2ATOKSCP_PID values ( 1 );

create table SEQ_OA2AUTHCODE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2AUTHCODE_PID values ( 1 );

create table SEQ_OA2CLIDETAASCOP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIDETAASCOP_PID values ( 1 );

create table SEQ_OA2CLIDETAGSCOP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIDETAGSCOP_PID values ( 1 );

create table SEQ_OA2CLIDETAUTHGRNTTYP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIDETAUTHGRNTTYP_PID values ( 1 );

create table SEQ_OA2CLIDETCLISEC_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIDETCLISEC_PID values ( 1 );

create table SEQ_OA2CLIDETREGREDIRURI_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIDETREGREDIRURI_PID values ( 1 );

create table SEQ_OA2CLIENTDETAILS_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIENTDETAILS_PID values ( 1 );

create table SEQ_OA2CLIENTDETAILSSCOPE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIENTDETAILSSCOPE_PID values ( 1 );

create table SEQ_OA2CLIENTPERM_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2CLIENTPERM_PID values ( 1 );

create table SEQ_OA2REFTOKEN_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2REFTOKEN_PID values ( 1 );

create table SEQ_OA2RTOKADNLINFO_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2RTOKADNLINFO_PID values ( 1 );

create table SEQ_OA2RTOKGRNTDA_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2RTOKGRNTDA_PID values ( 1 );

create table SEQ_OA2RTOKLNCHRESID_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2RTOKLNCHRESID_PID values ( 1 );

create table SEQ_OA2RTOKREQPRM_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2RTOKREQPRM_PID values ( 1 );

create table SEQ_OA2RTOKSCP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2RTOKSCP_PID values ( 1 );

create table SEQ_OA2SERVER_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_OA2SERVER_PID values ( 1 );

create table SEQ_USER_OA2CLN_TOS_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USER_OA2CLN_TOS_PID values ( 1 );

create table SEQ_USER_PERM_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USER_PERM_PID values ( 1 );

create table SEQ_USER_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USER_PID values ( 1 );

create table SEQ_USER_PSN_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USER_PSN_PID values ( 1 );

create table SEQ_USERDEFLNCHCTX_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USERDEFLNCHCTX_PID values ( 1 );

create table SEQ_USERTFAKEY_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USERTFAKEY_PID values ( 1 );

create table SEQ_USROA2CLNTAPRVDSCP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_USROA2CLNTAPRVDSCP_PID values ( 1 );

create table SEQ_XACT_LOG_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_XACT_LOG_PID values ( 1 );

create table SEQ_XACT_LOG_STEP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_XACT_LOG_STEP_PID values ( 1 );

create index IDX_AG_APPL_IDENTIFIER 
   on AG_APPL (IDENTIFIER);

create index IDX_AG_ATTEST_ARCHIVE_DATE 
   on AG_ATTESTATION (ARCHIVE_DATE);

alter table AG_DRAFT 
   add constraint IDX_AG_DRAFT_APPNAME_USER unique (APP_NAME, USER_PID);

alter table AG_OAUTH_REDIRECT 
   add constraint IDX_AG_OAUTH_REDIRECT_PID unique (OAUTH_REDIRECT_URL, PID);

create index IDX_AE_TGUID 
   on CDR_AUDIT_EVT (TRANSACTION_GUID);

create index IDX_CDRAUDITEVT_EVTTIMESTAMP 
   on CDR_AUDIT_EVT (EVT_TIMESTAMP);

create index IDX_AUDITEVT_HEADER_EVT 
   on CDR_AUDIT_EVT_HEADER (EVENT_PID);

create index IDX_AUDITEVT_TARGMOD_EVT 
   on CDR_AUDIT_EVT_TARGET_MODULE (EVENT_PID);

create index IDX_AUDITEVT_TARGRES_EVT 
   on CDR_AUDIT_EVT_TARGET_RES (EVENT_PID);

create index IDX_AUDITEVT_TARGUSR_EVT 
   on CDR_AUDIT_EVT_TARGET_USER (EVENT_PID);

alter table CDR_AUDIT_EVT_TYPE 
   add constraint IDX_AUDITEVTTYPE_SYSTEM_CODE unique (SYSTEM_URL, CODEVAL);

alter table CDR_CACHE_SYNC 
   add constraint IDX_CACHE_SYNC_ID unique (MODULE_PID, CACHE_ID);

alter table CDR_CDA_TEMPLATE 
   add constraint IDX_CDATEMPL_ID unique (TEMPLATE_ID);

create index IDX_HTTPSESSION_EXPIRY 
   on CDR_HTTP_SESSION (SES_EXPIRY);

create index IDX_HTTPSESSION_MODULE 
   on CDR_HTTP_SESSION (MODULE_PID);

alter table CDR_HTTP_SESSION 
   add constraint IDX_HTTPSESSION_ID unique (SES_ID);

create index IDX_GAUGE_MODCOLLINTSTART 
   on CDR_METRIC_GAUGE (MODPROC_PID, GAUGE_TYPE, INTERVL, START_TIME);

create index IDX_GAUGE_MODCOLLSTART 
   on CDR_METRIC_GAUGE (MODPROC_PID, IS_COLLAPSED, START_TIME);

alter table CDR_METRIC_HC 
   add constraint IDX_METRICHC_NODEP_HID unique (MODPROC_PID, HEALTHCHECK_TYPE);

alter table CDR_METRIC_HEALTH 
   add constraint IDX_METRICHC_MOD_TYPE_NAME unique (MODPROC_PID, HEALTHCHECK_TYPE, CUSTOM_HEALTHCHECK_NAME);

create index IDX_TIMER_MODCOLLINTSTART 
   on CDR_METRIC_TIMER (MODPROC_PID, TIMER_TYPE, INTERVL, START_TIME);

create index IDX_TIMER_MODCOLLSTART_V2 
   on CDR_METRIC_TIMER (START_TIME, MODPROC_PID, IS_COLLAPSED);

alter table CDR_MODULE 
   add constraint IDX_MODULE_ID unique (NODE_PID, MODULE_ID);

alter table CDR_MODULE_CFG_PROP 
   add constraint IDX_CDR_MODULE_CDR_PROP_MODKEY unique (MODULE_PID, PROTOTYPE_PID);

alter table CDR_MODULE_PROCESS 
   add constraint IDX_MODPROC_NODEPROC_MOD unique (NODEPROC_PID, MODULE_PID);

alter table CDR_MODULE_PROT_CFG 
   add constraint IDX_CDR_MODULE_PROT_CDG_MODKEY unique (PROTOTYPE_PID, CFG_KEY);

alter table CDR_MODULE_PROT_DEP 
   add constraint IDX_MODULEPROTDEP_PROT_KEY unique (PROTOTYPE_PID, ENTRY_KEY);

alter table CDR_MODULE_PROTOTYPE 
   add constraint IDX_MODULEPROTOTYPE_TYPE unique (MODULE_TYPE);

create index IDX_MODSTAT_MOD 
   on CDR_MODULE_STATE (MODULE_PID);

alter table CDR_MODULE_STATE 
   add constraint IDX_MODSTAT_MODTYPE unique (MODULE_PID, STATE_TYPE);

alter table CDR_NODE 
   add constraint IDX_NODE_ID unique (NODE_ID);

alter table CDR_NODE_PROCESS 
   add constraint IDX_NODEPROC_PROCID unique (PROCESS_ID);

alter table CDR_OA2_CLI_DET_AUTH_GRNT_TYP 
   add constraint IDX_OA2TOKGRTTYP_TOK_GRNT_TYP unique (CLIENT_PID, GRANT_TYPE);

alter table CDR_OA2_CLI_DET_AUTOAP_SCOPE 
   add constraint IDX_OA2CLIDETAASCOPE_TOK_SCOP unique (CLIENT_PID, SCOPE);

alter table CDR_OA2_CLI_DET_AUTOGRNT_SCOPE 
   add constraint IDX_OA2CLIDETAGSCOPE_TOK_SCOP unique (CLIENT_PID, SCOPE);

alter table CDR_OA2_CLI_DET_CLISEC 
   add constraint IDX_OA2CLIDETCLISEC_SECRET unique (CLIENT_PID, CLI_SECRET);

alter table CDR_OA2_CLI_DET_REG_REDIR_URI 
   add constraint IDX_OA2CLIDETRRURI_TOK_SCO unique (CLIENT_PID, REDIR_URI);

alter table CDR_OA2_SERVER 
   add constraint IDX_OA2SERVER_FED_REG_ID unique (MODULE_PID, FEDERATION_REG_ID, ARCHIVED_AT);

alter table CDR_OA2_SERVER 
   add constraint IDX_OA2SERVER_MODULE_ISSURL unique (MODULE_PID, ISS, ARCHIVED_AT);

create index IDX_OA2ATOKEN_TOKEN_HASH 
   on CDR_OAUTH2_ATOKEN (TOKEN_HASH);

create index IDX_OA2ATOKEN_USER 
   on CDR_OAUTH2_ATOKEN (USER_PID);

create index IDX_OA2ATOKEN_EXPIRATION 
   on CDR_OAUTH2_ATOKEN (EXPIRATION);

alter table CDR_OAUTH2_ATOKEN_ADNLINFO 
   add constraint IDX_OA2ATOKADLNF_ATOKEN_ADNLNF unique (TOKEN_PID, INFO_KEY);

create index IDX_OA2ATOKGRNT_ATOKEN_PERM 
   on CDR_OAUTH2_ATOKEN_GRNTDA (TOKEN_PID, PERM_NAME);

create index IDX_OA2ATOKSCP_SCP 
   on CDR_OAUTH2_ATOKEN_SCOPE (SCOPE, TOKEN_PID);

alter table CDR_OAUTH2_ATOKEN_SCOPE 
   add constraint IDX_OA2ATOKSCP_ATOKEN_SCOPE unique (TOKEN_PID, SCOPE);

create index IDX_OA2AUTHCODE_EXPIRATION 
   on CDR_OAUTH2_AUTH_CODE (EXPIRATION);

alter table CDR_OAUTH2_AUTH_CODE 
   add constraint IDX_OA2AUTHCODE_CODE unique (CODE_VAL);

alter table CDR_OAUTH2_CLIENT_DET_SCOPE 
   add constraint IDX_OA2CLIDETSCOP_TOKEN_SCOPE unique (CLIENT_PID, SCOPE);

alter table CDR_OAUTH2_CLIENT_DETAILS 
   add constraint IDX_OA2CLIENTDETAILS_CLI_MOD unique (MODULE_PID, CLIENT_ID, ARCHIVED_AT);

create index IDX_OA2JWTUNIQID_TIMESTAMP 
   on CDR_OAUTH2_JWT_UNIQ_ID (CONSUMED_TIMESTAMP);

create index IDX_OA2REFTOKEN_USER 
   on CDR_OAUTH2_REFRESH_TOKEN (USER_PID);

create index IDX_OA2REFTOKEN_EXPIRATION 
   on CDR_OAUTH2_REFRESH_TOKEN (EXPIRATION);

alter table CDR_OAUTH2_REFRESH_TOKEN 
   add constraint IDX_OA2REFTOKEN_TOKEN unique (TOKEN_VAL);

alter table CDR_OAUTH2_RTOKEN_ADNLINFO 
   add constraint IDX_OA2RTOKADLNF_RTOKEN_ADNLNF unique (TOKEN_PID, INFO_KEY);

alter table CDR_OAUTH2_RTOKEN_REQPRM 
   add constraint IDX_OA2RTOKREQPRM_RTOKEN_PARM unique (TOKEN_PID, PARM_KEY);

create index IDX_OA2RTOKSCP_SCP 
   on CDR_OAUTH2_RTOKEN_SCOPE (SCOPE, TOKEN_PID);

alter table CDR_OAUTH2_RTOKEN_SCOPE 
   add constraint IDX_OA2RTOKSCP_RTOKEN_SCOPE unique (TOKEN_PID, SCOPE);

create index IDX_NID_CR_VER 
   on CDR_RESTORE (NODE_PID, CREATED, VERSION);

create index FK_CDR_RESTORE_NODE 
   on CDR_RESTORE (NODE_PID);

create index FK_CDR_RESTORE_USER 
   on CDR_RESTORE (USER_PID);

create index IDX_USER_FAMILYNAME 
   on CDR_USER_DETAILS (MODULE_PID, FAMILY_NAME);

create index IDX_USER_GIVENNAME 
   on CDR_USER_DETAILS (MODULE_PID, GIVEN_NAME);

alter table CDR_USER_DETAILS 
   add constraint IDX_USERDET_MODULE_USERNAME unique (MODULE_PID, USERNAME);

create index IDX_USERDEFLNCHCTX_USER 
   on CDR_USER_DETAILS_DEF_LNCH_CTX (USER_PID);

alter table CDR_USER_DETAILS_DEF_LNCH_CTX 
   add constraint IDX_USERDEFLNCHCTX_USER_CTYP unique (USER_PID, CONTEXT_TYPE);

create index IDX_USROA2CLNTAPRVDSCP_CLNTUSR 
   on CDR_USER_DETAILS_OA2CLNAPRVSCP (CLIENT_PID, USER_PID);

create index IDX_USER_OA2CLN_TOS_USRCLNT 
   on CDR_USER_OA2CLN_TOS (USER_PID, CLIENT_PID);

create index IDX_USER_PERM_PERM_USER 
   on CDR_USER_PERM (PERMISSION_TYPE, USER_PID);

create index IDX_USER_PSN_USR 
   on CDR_USER_PSN (USER_PID, VERSION, CREATED_DATE, REVOKED_DATE);

alter table CDR_USER_TFA_KEY 
   add constraint IDX_USERTFAKEY_USER unique (USER_PID);

create index IDX_XACTLOG_INITTS 
   on CDR_XACT_LOG (INITIAL_TIMESTAMP);

create index IDX_XACTID 
   on CDR_XACT_LOG (SRC_XACT_ID);

alter table CDR_XACT_LOG 
   add constraint IDX_GUID unique (SRC_GUID);

create index IDX_XACTLOGSTEP_LOGID 
   on CDR_XACT_LOG_STEP (LOG_PID);

alter table AG_ADDRESS 
   add constraint FK_AG_ADDRESS_AG_PROFILE 
   foreign key (AG_PROFILE_PID) 
   references AG_PROFILE (PID);

alter table AG_APP_REQUEST 
   add constraint FK_AG_APP_REQUEST_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_JWK_SET 
   foreign key (JWK_SET_PID) 
   references AG_DATA (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_AG_ATTESTATION 
   foreign key (ATTESTATION_PID) 
   references AG_ATTESTATION (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_ICON 
   foreign key (ICON_PID) 
   references AG_DATA (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_OAUTH2_CLIENT 
   foreign key (OAUTH2_CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_PARENT_PID 
   foreign key (PARENT_PID) 
   references AG_APPL (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_AG_PROFILE 
   foreign key (PROFILE_PID) 
   references AG_PROFILE (PID);

alter table AG_APPL 
   add constraint FK_AG_APPL_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table AG_ATTESTATION 
   add constraint FK_AG_ATTESTATION_HTML 
   foreign key (HTML_PID) 
   references AG_DATA (PID);

alter table AG_ATTESTATION 
   add constraint FK_AG_ATTESTATION_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table AG_ATTESTATION 
   add constraint FK_AG_ATTESTATION_PLAIN_HTML 
   foreign key (PLAIN_HTML_PID) 
   references AG_DATA (PID);

alter table AG_CLASS 
   add constraint FK_AG_CLASS_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_COUNTRY 
   add constraint FK_AG_COUNTRY_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_DOCUMENT 
   add constraint FK_AG_DOCUMENT_DATA_BLOB 
   foreign key (DOCUMENT_PID) 
   references AG_DATA (PID);

alter table AG_DOCUMENT 
   add constraint FK_AG_DOCUMENT_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_DRAFT 
   add constraint FK_AG_DRAFT_DATA_BLOB 
   foreign key (DRAFT_PID) 
   references AG_DATA (PID);

alter table AG_DRAFT 
   add constraint FK_AG_DRAFT_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table AG_DRAFT 
   add constraint FK_AG_DRAFT_SOURCE_APP_PID 
   foreign key (SOURCE_APP_PID) 
   references AG_APPL (PID);

alter table AG_DRAFT 
   add constraint FK_AG_DRAFT_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table AG_MEMBER_PHONE 
   add constraint FK_AG_MEMBER_PHONE_APP_REQUEST 
   foreign key (AG_APP_REQUEST_PID) 
   references AG_APP_REQUEST (PID);

alter table AG_METADATA 
   add constraint FK_AG_METADATA_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_NOTE 
   add constraint FK_AG_NOTE_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_OAUTH_REDIRECT 
   add constraint FK_AG_OAUTH_REDIRECT_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_PERMISSION 
   add constraint FK_AG_PERMISSION_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_PHONE 
   add constraint FK_AG_PHONE_AG_PROFILE 
   foreign key (AG_PROFILE_PID) 
   references AG_PROFILE (PID);

alter table AG_PREREQUISITE 
   add constraint FK_AG_PREREQUISITE_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_PROFILE 
   add constraint FK_AG_PROFILE_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table AG_PROFILE 
   add constraint FK_AG_PROFILE_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table AG_SANDBOX_CLIENT 
   add constraint FK_AG_SANDBOX_CLIENT_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table AG_SANDBOX_CLIENT 
   add constraint FK_AG_CLIENT_OAUTH2_CLIENT 
   foreign key (OAUTH2_CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table AG_SANDBOX_CLIENT 
   add constraint FK_AG_SANDBOX_CLIENT_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table AG_SCOPE 
   add constraint FK_AG_SCOPE_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table AG_SCREENSHOT 
   add constraint FK_AG_SCREENSHOT_DATA_BLOB 
   foreign key (SCREENSHOT_PID) 
   references AG_DATA (PID);

alter table AG_SCREENSHOT 
   add constraint FK_AG_SCREENSHOT_AG_APPL 
   foreign key (AG_APPL_PID) 
   references AG_APPL (PID);

alter table CDR_AUDIT_EVT 
   add constraint FK_AUDITEVT_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_AUDIT_EVT 
   add constraint FK_AUDITEVT_ENDPOINTMODULE 
   foreign key (ENDPOINT_MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_AUDIT_EVT 
   add constraint FK_AUDITEVT_TYPE 
   foreign key (TYPE_PID) 
   references CDR_AUDIT_EVT_TYPE (PID);

alter table CDR_AUDIT_EVT 
   add constraint FK_AUDITEVT_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_AUDIT_EVT_HEADER 
   add constraint FK_AUDITEVT_HEADER_EVT 
   foreign key (EVENT_PID) 
   references CDR_AUDIT_EVT (PID);

alter table CDR_AUDIT_EVT_TARGET_MODULE 
   add constraint FK_AUDITEVT_TARGETMODULE_EVT 
   foreign key (EVENT_PID) 
   references CDR_AUDIT_EVT (PID);

alter table CDR_AUDIT_EVT_TARGET_MODULE 
   add constraint FK_AUDITEVT_TARGETMOD_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_AUDIT_EVT_TARGET_RES 
   add constraint FK_AUDITEVT_TARGETRES_EVT 
   foreign key (EVENT_PID) 
   references CDR_AUDIT_EVT (PID);

alter table CDR_AUDIT_EVT_TARGET_RES 
   add constraint FK_AUDITEVT_TARGETRES_PERSMOD 
   foreign key (PERS_MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_AUDIT_EVT_TARGET_USER 
   add constraint FK_AUDITEVT_TARGETUSER_EVT 
   foreign key (EVENT_PID) 
   references CDR_AUDIT_EVT (PID);

alter table CDR_AUDIT_EVT_TARGET_USER 
   add constraint FK_AUDITEVT_TARGETUSER_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_CACHE_SYNC 
   add constraint FK_CACHE_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_CDA_TEMPLATE 
   add constraint FK_CDA_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_CDA_TEMPLATE_PARAM 
   add constraint FK_CDATEMPLATE_PID 
   foreign key (TEMPLATE_PID) 
   references CDR_CDA_TEMPLATE (PID);

alter table CDR_HTTP_SESSION 
   add constraint FK_HTTPSESSION_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_IDENTIFICATION_CODES 
   add constraint FK_IDCODE_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_METRIC_GAUGE 
   add constraint FK_METGAUGE_MODP 
   foreign key (MODPROC_PID) 
   references CDR_MODULE_PROCESS (PID);

alter table CDR_METRIC_HC 
   add constraint FK_HC_MODP 
   foreign key (MODPROC_PID) 
   references CDR_MODULE_PROCESS (PID);

alter table CDR_METRIC_HEALTH 
   add constraint FK_HEALTH_MODP 
   foreign key (MODPROC_PID) 
   references CDR_MODULE_PROCESS (PID);

alter table CDR_METRIC_TIMER 
   add constraint FK_METTIMER_MODP 
   foreign key (MODPROC_PID) 
   references CDR_MODULE_PROCESS (PID);

alter table CDR_MODULE 
   add constraint FK_MODULE_NODE 
   foreign key (NODE_PID) 
   references CDR_NODE (PID);

alter table CDR_MODULE 
   add constraint FK_MODULE_PROTOTYPE 
   foreign key (PROTOTYPE_PID) 
   references CDR_MODULE_PROTOTYPE (PID);

alter table CDR_MODULE_CFG_PROP 
   add constraint FK_MODULECFGPROP_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_MODULE_CFG_PROP 
   add constraint FK_MODULECFGPROP_PROTOTYPE 
   foreign key (PROTOTYPE_PID) 
   references CDR_MODULE_PROT_CFG (PID);

alter table CDR_MODULE_DEP 
   add constraint FK_MODULEDEP_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_MODULE_DEP 
   add constraint FK_MODULEDEP_PROTOTYPE 
   foreign key (PROTOTYPE_PID) 
   references CDR_MODULE_PROT_DEP (PID);

alter table CDR_MODULE_DEP 
   add constraint FK_MODULEDEP_TARGET 
   foreign key (TARGET_PID) 
   references CDR_MODULE (PID);

alter table CDR_MODULE_PROCESS 
   add constraint FK_MODPROC_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_MODULE_PROCESS 
   add constraint FK_MODPROC_NODEPROC 
   foreign key (NODEPROC_PID) 
   references CDR_NODE_PROCESS (PID);

alter table CDR_MODULE_PROT_CFG 
   add constraint FK_CDR_MODULEPROTCFG_PROT 
   foreign key (PROTOTYPE_PID) 
   references CDR_MODULE_PROTOTYPE (PID);

alter table CDR_MODULE_PROT_DEP 
   add constraint FK_MODULE_PROT_DEP_PROT 
   foreign key (PROTOTYPE_PID) 
   references CDR_MODULE_PROTOTYPE (PID);

alter table CDR_MODULE_PROT_SUPPLIES 
   add constraint FK_MODULE_PROT_SUPPLIES_PROT 
   foreign key (PROTOTYPE_PID) 
   references CDR_MODULE_PROTOTYPE (PID);

alter table CDR_MODULE_STATE 
   add constraint FK_MODSTAT_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_NODE_MODULE_DIAGNOSTICS 
   add constraint FK_MULTI_NODE_MODULE_PID 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_NODE_MODULE_DIAGNOSTICS 
   add constraint FK_MULTI_NODE_PID 
   foreign key (NODE_PID) 
   references CDR_NODE (PID);

alter table CDR_NODE_PROCESS 
   add constraint FK_NODEPROCESS_NODE 
   foreign key (NODE_PID) 
   references CDR_NODE (PID);

alter table CDR_OA2_CLI_DET_AUTH_GRNT_TYP 
   add constraint FK_OA2CLIDETAUTHGRNTTY_CLI 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OA2_CLI_DET_AUTOAP_SCOPE 
   add constraint FK_OA2CLIDETAUTOAPPSCOP_CLI 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OA2_CLI_DET_AUTOGRNT_SCOPE 
   add constraint FK_OA2CLIDETAUTOGRNTPSCOP_CLI 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OA2_CLI_DET_CLISEC 
   add constraint FK_OA2CLIDETCLISEC_CLI 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OA2_CLI_DET_REG_REDIR_URI 
   add constraint FK_OA2CLIDETREGREDURI_CLI 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OA2_SERVER 
   add constraint FK_OA2SERVER_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_OAUTH2_ATOKEN 
   add constraint FK_OA2ATOKEN_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OAUTH2_ATOKEN 
   add constraint FK_OA2ATOKEN_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_OAUTH2_ATOKEN 
   add constraint FK_OA2ATOKEN_REF_TOK 
   foreign key (REFRESH_TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_ATOKEN 
   add constraint FK_OA2ATOKEN_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_OAUTH2_ATOKEN_ADNLINFO 
   add constraint FK_OA2ATOKADNLINFO_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_ATOKEN (PID);

alter table CDR_OAUTH2_ATOKEN_GRNTDA 
   add constraint FK_OA2ATOKGRNTDA_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_ATOKEN (PID);

alter table CDR_OAUTH2_ATOKEN_SCOPE 
   add constraint FK_OA2ATOKSCP_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_ATOKEN (PID);

alter table CDR_OAUTH2_ATOKEN_UDATA 
   add constraint FK_OA2ATOKUD_TOKEN 
   foreign key (ATOKEN_PID) 
   references CDR_OAUTH2_ATOKEN (PID);

alter table CDR_OAUTH2_ATOKEN_UDATA_BIN 
   add constraint FK_OA2ATOKUDBIN_TOKEN 
   foreign key (ATOKEN_PID) 
   references CDR_OAUTH2_ATOKEN (PID);

alter table CDR_OAUTH2_CLIENT_DET_SCOPE 
   add constraint FK_OA2CLIDETSCOP_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OAUTH2_CLIENT_DETAILS 
   add constraint FK_OA2CLIENTDETAILS_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_OAUTH2_CLIENT_PERM 
   add constraint FK_OA2CLIENTPERM_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OAUTH2_REFRESH_TOKEN 
   add constraint FK_OA2REFTOKEN_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_OAUTH2_REFRESH_TOKEN 
   add constraint FK_OA2REFTOKEN_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_OAUTH2_RTOKEN_ADNLINFO 
   add constraint FK_OA2RTOKADNLINFO_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_RTOKEN_GRNTDA 
   add constraint FK_OA2RTOKGRNTDA_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_RTOKEN_LNCHRESID 
   add constraint FK_OA2RTOKLNCHRESID_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_RTOKEN_REQPRM 
   add constraint FK_OA2RTOKREQPRM_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_RTOKEN_SCOPE 
   add constraint FK_OA2RTOKSCP_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_RTOKEN_UDATA 
   add constraint FK_OA2RTOKUD_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_OAUTH2_RTOKEN_UDATA_BIN 
   add constraint FK_OA2RTOKUDBIN_TOKEN 
   foreign key (TOKEN_PID) 
   references CDR_OAUTH2_REFRESH_TOKEN (PID);

alter table CDR_RESTORE 
   add constraint FK_CDR_RESTORE_NODE 
   foreign key (NODE_PID) 
   references CDR_NODE (PID);

alter table CDR_RESTORE 
   add constraint FK_CDR_RESTORE_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_USER_DETAILS 
   add constraint FK_USERDETAILS_MODULE 
   foreign key (MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_USER_DETAILS_DEF_LNCH_CTX 
   add constraint FK_USERDEFLNCHCTX_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_USER_DETAILS_OA2CLNAPRVSCP 
   add constraint FK_USROA2CLNTAPRVDSCP_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_USER_DETAILS_OA2CLNAPRVSCP 
   add constraint FK_USROA2CLNTAPRVDSCP_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_USER_OA2CLN_TOS 
   add constraint FK_USER_OA2CLN_TOS_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_USER_OA2CLN_TOS 
   add constraint FK_USER_OA2CLN_TOS_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_USER_PERM 
   add constraint FK_USERPERM_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_USER_PSN 
   add constraint FK_USER_PSN_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_USER_TFA_KEY 
   add constraint FK_USERTFAKEY_USER 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_XACT_LOG 
   add constraint FK_TRANSIT_CLIENT 
   foreign key (CLIENT_PID) 
   references CDR_OAUTH2_CLIENT_DETAILS (PID);

alter table CDR_XACT_LOG 
   add constraint FK_XACTLOGSTEP_MODULE 
   foreign key (CDR_ENDPOINT_MODULE_PID) 
   references CDR_MODULE (PID);

alter table CDR_XACT_LOG 
   add constraint FK_TRANSIT_EVENT 
   foreign key (USER_PID) 
   references CDR_USER_DETAILS (PID);

alter table CDR_XACT_LOG_STEP 
   add constraint FK_XACTLOGSTEP_XACTLOG 
   foreign key (LOG_PID) 
   references CDR_XACT_LOG (PID);

41.4.6Setting up a FHIR Storage (Relational) Database

 

To initialize a new MySQL database for FHIR Storage (Relational), initialize a database with the following SQL:

create table BT2_JOB_INSTANCE (
    ID varchar(100) not null,
    JOB_CANCELLED bit not null,
    CMB_RECS_PROCESSED integer,
    CMB_RECS_PER_SEC float(53),
    CREATE_TIME datetime(6) not null,
    CUR_GATED_STEP_ID varchar(100),
    DEFINITION_ID varchar(100) not null,
    DEFINITION_VER integer not null,
    END_TIME datetime(6),
    ERROR_COUNT integer not null,
    ERROR_MSG varchar(500),
    EST_REMAINING varchar(100),
    FAST_TRACKING bit,
    PARAMS_JSON varchar(2000),
    PARAMS_JSON_LOB tinytext,
    PARAMS_JSON_VC longtext,
    PROGRESS_PCT float(53) not null,
    REPORT longtext,
    REPORT_VC longtext,
    START_TIME datetime(6),
    STAT enum ('QUEUED','IN_PROGRESS','FINALIZE','COMPLETED','ERRORED','FAILED','CANCELLED') not null,
    TOT_ELAPSED_MILLIS integer,
    CLIENT_ID varchar(200),
    USER_NAME varchar(200),
    UPDATE_TIME datetime(6),
    WARNING_MSG varchar(4000),
    WORK_CHUNKS_PURGED bit not null,
    primary key (ID)
) engine=InnoDB;

create table BT2_WORK_CHUNK (
    ID varchar(100) not null,
    CREATE_TIME datetime(6) not null,
    END_TIME datetime(6),
    ERROR_COUNT integer not null,
    ERROR_MSG varchar(500),
    INSTANCE_ID varchar(100) not null,
    DEFINITION_ID varchar(100) not null,
    DEFINITION_VER integer not null,
    NEXT_POLL_TIME datetime(6),
    POLL_ATTEMPTS integer,
    RECORDS_PROCESSED integer,
    SEQ integer not null,
    CHUNK_DATA longtext,
    CHUNK_DATA_VC longtext,
    START_TIME datetime(6),
    STAT enum ('READY','GATE_WAITING','REDUCTION_READY','QUEUED','IN_PROGRESS','POLL_WAITING','ERRORED','FAILED','COMPLETED') not null,
    TGT_STEP_ID varchar(100) not null,
    UPDATE_TIME datetime(6),
    WARNING_MSG varchar(4000),
    primary key (ID)
) engine=InnoDB;

create table CDH_LB_REF (
    PID bigint not null,
    EXPIRES datetime(6),
    LB_RES_ID bigint not null,
    ORDER_DATE datetime(6),
    ROOT_RES_ID bigint not null,
    RULE_SYSTEM varchar(200) not null,
    RULE_VALUE varchar(200) not null,
    SUBS_RES_ID bigint not null,
    TRACK_PARAM varchar(200),
    TRACK_SUBPARAM varchar(200),
    primary key (PID)
) engine=InnoDB;

create table CDH_LB_SUB_GROUP (
    PID bigint not null,
    SUBS_GROUP varchar(200) not null,
    SUBS_ID varchar(200) not null,
    SUBS_RES_ID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table CDH_LB_WL (
    PID bigint not null,
    SUBSCRIBER_TYPE varchar(200) not null,
    WATCHLIST_SYSTEM varchar(200) not null,
    WATCHLIST_VALUE varchar(200) not null,
    primary key (PID)
) engine=InnoDB;

create table CDH_LB_WL_SUBS (
    PID bigint not null,
    SEED_STATUS integer not null,
    SUBS_ID varchar(200) not null,
    SUBS_RES_ID bigint not null,
    WATCHLIST_ID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_BINARY_STORAGE_BLOB (
    BLOB_ID varchar(200) not null,
    BLOB_DATA mediumblob,
    CONTENT_TYPE varchar(100) not null,
    BLOB_HASH varchar(128),
    PUBLISHED_DATE datetime(6) not null,
    RESOURCE_ID varchar(100) not null,
    BLOB_SIZE bigint not null,
    STORAGE_CONTENT_BIN longblob,
    primary key (BLOB_ID)
) engine=InnoDB;

create table HFJ_BLK_EXPORT_COLFILE (
    PID bigint not null,
    RES_ID varchar(100) not null,
    COLLECTION_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_BLK_EXPORT_COLLECTION (
    PID bigint not null,
    TYPE_FILTER varchar(1000),
    RES_TYPE varchar(40) not null,
    OPTLOCK integer not null,
    JOB_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_BLK_EXPORT_JOB (
    PID bigint not null,
    CREATED_TIME datetime(6) not null,
    EXP_TIME datetime(6),
    JOB_ID varchar(36) not null,
    REQUEST varchar(1024) not null,
    EXP_SINCE datetime(6),
    JOB_STATUS varchar(10) not null,
    STATUS_MESSAGE varchar(500),
    STATUS_TIME datetime(6) not null,
    OPTLOCK integer not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_BLK_IMPORT_JOB (
    PID bigint not null,
    BATCH_SIZE integer not null,
    FILE_COUNT integer not null,
    JOB_DESC varchar(500),
    JOB_ID varchar(36) not null,
    ROW_PROCESSING_MODE enum ('FHIR_TRANSACTION') not null,
    JOB_STATUS enum ('STAGING','READY','RUNNING','COMPLETE','ERROR') not null,
    STATUS_MESSAGE varchar(500),
    STATUS_TIME datetime(6) not null,
    OPTLOCK integer not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_BLK_IMPORT_JOBFILE (
    PID bigint not null,
    JOB_CONTENTS tinyblob,
    JOB_CONTENTS_VC longtext,
    FILE_DESCRIPTION varchar(500),
    FILE_SEQ integer not null,
    TENANT_NAME varchar(200),
    JOB_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_FORCED_ID (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    FORCED_ID varchar(100) not null,
    RESOURCE_PID bigint not null,
    RESOURCE_TYPE varchar(100) default '',
    primary key (PID)
) engine=InnoDB;

create table HFJ_HISTORY_TAG (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    TAG_ID bigint,
    RES_VER_PID bigint not null,
    RES_ID bigint not null,
    RES_TYPE varchar(40) not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_IDX_CMB_TOK_NU (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_COMPLETE bigint not null,
    IDX_STRING varchar(500) not null,
    RES_ID bigint,
    primary key (PID)
) engine=InnoDB;

create table HFJ_IDX_CMP_STRING_UNIQ (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_COMPLETE bigint,
    HASH_COMPLETE_2 bigint,
    IDX_STRING varchar(500) not null,
    RES_ID bigint,
    primary key (PID)
) engine=InnoDB;

create table HFJ_PARTITION (
    PART_ID integer not null,
    PART_DESC varchar(200),
    PART_NAME varchar(200) not null,
    primary key (PART_ID)
) engine=InnoDB;

create table HFJ_RES_LINK (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    SRC_PATH varchar(500) not null,
    SRC_RESOURCE_ID bigint not null,
    SOURCE_RESOURCE_TYPE varchar(40) not null,
    TARGET_RES_PARTITION_DATE date,
    TARGET_RES_PARTITION_ID integer,
    TARGET_RESOURCE_ID bigint,
    TARGET_RESOURCE_TYPE varchar(40) not null,
    TARGET_RESOURCE_URL varchar(200),
    TARGET_RESOURCE_VERSION bigint,
    SP_UPDATED datetime(6),
    primary key (PID)
) engine=InnoDB;

create table HFJ_RES_PARAM_PRESENT (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_PRESENCE bigint,
    SP_PRESENT bit not null,
    RES_ID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_RES_REINDEX_JOB (
    PID bigint not null,
    JOB_DELETED bit not null,
    REINDEX_COUNT integer,
    RES_TYPE varchar(100),
    SUSPENDED_UNTIL datetime(6),
    UPDATE_THRESHOLD_HIGH datetime(6) not null,
    UPDATE_THRESHOLD_LOW datetime(6),
    primary key (PID)
) engine=InnoDB;

create table HFJ_RES_SEARCH_URL (
    RES_SEARCH_URL varchar(768) not null,
    PARTITION_ID integer not null,
    CREATED_TIME datetime(6) not null,
    PARTITION_DATE date,
    RES_ID bigint not null,
    primary key (RES_SEARCH_URL, PARTITION_ID)
) engine=InnoDB;

create table HFJ_RES_TAG (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    TAG_ID bigint,
    RES_ID bigint,
    RES_TYPE varchar(40) not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_RES_VER (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    RES_DELETED_AT datetime(6),
    RES_VERSION enum ('DSTU2','DSTU2_HL7ORG','DSTU2_1','DSTU3','R4','R4B','R5'),
    HAS_TAGS bit not null,
    RES_PUBLISHED datetime(6) not null,
    RES_UPDATED datetime(6) not null,
    RES_ENCODING enum ('JSON','JSONC','DEL','ESR') not null,
    REQUEST_ID varchar(16),
    RES_TEXT longblob,
    RES_ID bigint not null,
    RES_TEXT_VC longtext,
    RES_TYPE varchar(40) not null,
    RES_VER bigint not null,
    SOURCE_URI varchar(100),
    primary key (PID)
) engine=InnoDB;

create table HFJ_RES_VER_PROV (
    RES_VER_PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    REQUEST_ID varchar(16),
    SOURCE_URI varchar(100),
    RES_PID bigint not null,
    primary key (RES_VER_PID)
) engine=InnoDB;

create table HFJ_RESOURCE (
    RES_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    RES_DELETED_AT datetime(6),
    RES_VERSION enum ('DSTU2','DSTU2_HL7ORG','DSTU2_1','DSTU3','R4','R4B','R5'),
    HAS_TAGS bit not null,
    RES_PUBLISHED datetime(6) not null,
    RES_UPDATED datetime(6) not null,
    FHIR_ID varchar(64),
    SP_HAS_LINKS bit not null,
    HASH_SHA256 varchar(64),
    SP_INDEX_STATUS bigint,
    RES_LANGUAGE varchar(20),
    SP_CMPSTR_UNIQ_PRESENT bit,
    SP_CMPTOKS_PRESENT bit,
    SP_COORDS_PRESENT bit not null,
    SP_DATE_PRESENT bit not null,
    SP_NUMBER_PRESENT bit not null,
    SP_QUANTITY_NRML_PRESENT bit not null,
    SP_QUANTITY_PRESENT bit not null,
    SP_STRING_PRESENT bit not null,
    SP_TOKEN_PRESENT bit not null,
    SP_URI_PRESENT bit not null,
    RES_TYPE varchar(40) not null,
    SEARCH_URL_PRESENT bit,
    RES_VER bigint not null,
    primary key (RES_ID)
) engine=InnoDB;

create table HFJ_RESOURCE_MODIFIED (
    RES_ID varchar(256) not null,
    RES_VER varchar(8) not null,
    CREATED_TIME datetime(6) not null,
    RESOURCE_TYPE varchar(40) not null,
    SUMMARY_MESSAGE varchar(4000) not null,
    primary key (RES_ID, RES_VER)
) engine=InnoDB;

create table HFJ_REVINFO (
    REV bigint not null,
    REVTSTMP datetime(6),
    primary key (REV)
) engine=InnoDB;

create table HFJ_SEARCH (
    PID bigint not null,
    CREATED datetime(6) not null,
    SEARCH_DELETED bit,
    EXPIRY_OR_NULL datetime(6),
    FAILURE_CODE integer,
    FAILURE_MESSAGE varchar(500),
    LAST_UPDATED_HIGH datetime(6),
    LAST_UPDATED_LOW datetime(6),
    NUM_BLOCKED integer,
    NUM_FOUND integer not null,
    PREFERRED_PAGE_SIZE integer,
    RESOURCE_ID bigint,
    RESOURCE_TYPE varchar(200),
    SEARCH_PARAM_MAP tinyblob,
    SEARCH_PARAM_MAP_BIN longblob,
    SEARCH_QUERY_STRING text,
    SEARCH_QUERY_STRING_HASH integer,
    SEARCH_QUERY_STRING_VC longtext,
    SEARCH_TYPE integer not null,
    SEARCH_STATUS enum ('LOADING','PASSCMPLET','FINISHED','FAILED','GONE') not null,
    TOTAL_COUNT integer,
    SEARCH_UUID varchar(48) not null,
    OPTLOCK_VERSION integer,
    primary key (PID)
) engine=InnoDB;

create table HFJ_SEARCH_INCLUDE (
    PID bigint not null,
    SEARCH_INCLUDE varchar(200) not null,
    INC_RECURSE bit not null,
    REVINCLUDE bit not null,
    SEARCH_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_SEARCH_RESULT (
    PID bigint not null,
    SEARCH_ORDER integer not null,
    RESOURCE_PID bigint not null,
    SEARCH_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table HFJ_SPIDX_COORDS (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    SP_LATITUDE float(53),
    SP_LONGITUDE float(53),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_DATE (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    SP_VALUE_HIGH datetime(6),
    SP_VALUE_HIGH_DATE_ORDINAL integer,
    SP_VALUE_LOW datetime(6),
    SP_VALUE_LOW_DATE_ORDINAL integer,
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_NUMBER (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    SP_VALUE decimal(19,2),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_QUANTITY (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    HASH_IDENTITY_AND_UNITS bigint,
    HASH_IDENTITY_SYS_UNITS bigint,
    SP_SYSTEM varchar(200),
    SP_UNITS varchar(200),
    SP_VALUE float(53),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_QUANTITY_NRML (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    HASH_IDENTITY_AND_UNITS bigint,
    HASH_IDENTITY_SYS_UNITS bigint,
    SP_SYSTEM varchar(200),
    SP_UNITS varchar(200),
    SP_VALUE float(53),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_STRING (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    HASH_EXACT bigint,
    HASH_NORM_PREFIX bigint,
    SP_VALUE_EXACT varchar(768),
    SP_VALUE_NORMALIZED varchar(768),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_TOKEN (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    HASH_SYS bigint,
    HASH_SYS_AND_VALUE bigint,
    HASH_VALUE bigint,
    SP_SYSTEM varchar(200),
    SP_VALUE varchar(200),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SPIDX_URI (
    SP_ID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    HASH_IDENTITY bigint,
    SP_MISSING bit not null,
    SP_NAME varchar(100),
    RES_ID bigint not null,
    RES_TYPE varchar(100),
    SP_UPDATED datetime(6),
    HASH_URI bigint,
    SP_URI varchar(500),
    primary key (SP_ID)
) engine=InnoDB;

create table HFJ_SUBSCRIPTION_STATS (
    PID bigint not null,
    CREATED_TIME datetime(6) not null,
    RES_ID bigint,
    primary key (PID)
) engine=InnoDB;

create table HFJ_TAG_DEF (
    TAG_ID bigint not null,
    TAG_CODE varchar(200),
    TAG_DISPLAY varchar(200),
    TAG_SYSTEM varchar(200),
    TAG_TYPE integer not null,
    TAG_USER_SELECTED bit,
    TAG_VERSION varchar(30),
    primary key (TAG_ID)
) engine=InnoDB;

create table MPI_LINK (
    PID bigint not null,
    PARTITION_DATE date,
    PARTITION_ID integer,
    CREATED datetime(6) not null,
    EID_MATCH bit,
    GOLDEN_RESOURCE_PID bigint not null,
    NEW_PERSON bit,
    LINK_SOURCE integer not null,
    MATCH_RESULT integer not null,
    TARGET_TYPE varchar(40),
    PERSON_PID bigint not null,
    RULE_COUNT bigint,
    SCORE float(53),
    TARGET_PID bigint not null,
    UPDATED datetime(6) not null,
    VECTOR bigint,
    VERSION varchar(16) not null,
    primary key (PID)
) engine=InnoDB;

create table MPI_LINK_AUD (
    PID bigint not null,
    REV bigint not null,
    REVTYPE tinyint,
    PARTITION_DATE date,
    PARTITION_ID integer,
    CREATED datetime(6),
    EID_MATCH bit,
    GOLDEN_RESOURCE_PID bigint,
    NEW_PERSON bit,
    LINK_SOURCE integer,
    MATCH_RESULT integer,
    TARGET_TYPE varchar(40),
    PERSON_PID bigint,
    RULE_COUNT bigint,
    SCORE float(53),
    TARGET_PID bigint,
    UPDATED datetime(6),
    VECTOR bigint,
    VERSION varchar(16),
    primary key (REV, PID)
) engine=InnoDB;

create table NPM_PACKAGE (
    PID bigint not null,
    CUR_VERSION_ID varchar(200),
    PACKAGE_DESC varchar(200),
    PACKAGE_ID varchar(200) not null,
    UPDATED_TIME datetime(6) not null,
    primary key (PID)
) engine=InnoDB;

create table NPM_PACKAGE_VER (
    PID bigint not null,
    CURRENT_VERSION bit not null,
    PKG_DESC varchar(200),
    DESC_UPPER varchar(200),
    FHIR_VERSION enum ('DSTU2','DSTU2_HL7ORG','DSTU2_1','DSTU3','R4','R4B','R5') not null,
    FHIR_VERSION_ID varchar(20) not null,
    PACKAGE_ID varchar(200) not null,
    PACKAGE_SIZE_BYTES bigint not null,
    SAVED_TIME datetime(6) not null,
    UPDATED_TIME datetime(6) not null,
    VERSION_ID varchar(200) not null,
    PACKAGE_PID bigint not null,
    BINARY_RES_ID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table NPM_PACKAGE_VER_RES (
    PID bigint not null,
    CANONICAL_URL varchar(200),
    CANONICAL_VERSION varchar(200),
    FILE_DIR varchar(200),
    FHIR_VERSION enum ('DSTU2','DSTU2_HL7ORG','DSTU2_1','DSTU3','R4','R4B','R5') not null,
    FHIR_VERSION_ID varchar(20) not null,
    FILE_NAME varchar(200),
    RES_SIZE_BYTES bigint not null,
    RES_TYPE varchar(40) not null,
    UPDATED_TIME datetime(6) not null,
    PACKVER_PID bigint not null,
    BINARY_RES_ID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table SEQ_BLKEXCOL_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_BLKEXCOL_PID values ( 1 );

create table SEQ_BLKEXCOLFILE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_BLKEXCOLFILE_PID values ( 1 );

create table SEQ_BLKEXJOB_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_BLKEXJOB_PID values ( 1 );

create table SEQ_BLKIMJOB_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_BLKIMJOB_PID values ( 1 );

create table SEQ_BLKIMJOBFILE_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_BLKIMJOBFILE_PID values ( 1 );

create table SEQ_CDH_LB_REF (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDH_LB_REF values ( 1 );

create table SEQ_CDH_LB_SUB_GROUP (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDH_LB_SUB_GROUP values ( 1 );

create table SEQ_CDH_LB_WL (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDH_LB_WL values ( 1 );

create table SEQ_CDH_LB_WL_SUBS (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CDH_LB_WL_SUBS values ( 1 );

create table SEQ_CNCPT_MAP_GRP_ELM_TGT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CNCPT_MAP_GRP_ELM_TGT_PID values ( 1 );

create table SEQ_CODESYSTEM_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CODESYSTEM_PID values ( 1 );

create table SEQ_CODESYSTEMVER_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CODESYSTEMVER_PID values ( 1 );

create table SEQ_CONCEPT_DESIG_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_DESIG_PID values ( 1 );

create table SEQ_CONCEPT_MAP_GROUP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_MAP_GROUP_PID values ( 1 );

create table SEQ_CONCEPT_MAP_GRP_ELM_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_MAP_GRP_ELM_PID values ( 1 );

create table SEQ_CONCEPT_MAP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_MAP_PID values ( 1 );

create table SEQ_CONCEPT_PC_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_PC_PID values ( 1 );

create table SEQ_CONCEPT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_PID values ( 1 );

create table SEQ_CONCEPT_PROP_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_CONCEPT_PROP_PID values ( 1 );

create table SEQ_EMPI_LINK_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_EMPI_LINK_ID values ( 1 );

create table SEQ_FORCEDID_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_FORCEDID_ID values ( 1 );

create table SEQ_HFJ_REVINFO (
    next_val bigint
) engine=InnoDB;

insert into SEQ_HFJ_REVINFO values ( 1 );

create table SEQ_HISTORYTAG_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_HISTORYTAG_ID values ( 1 );

create table SEQ_IDXCMBTOKNU_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_IDXCMBTOKNU_ID values ( 1 );

create table SEQ_IDXCMPSTRUNIQ_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_IDXCMPSTRUNIQ_ID values ( 1 );

create table SEQ_NPM_PACK (
    next_val bigint
) engine=InnoDB;

insert into SEQ_NPM_PACK values ( 1 );

create table SEQ_NPM_PACKVER (
    next_val bigint
) engine=InnoDB;

insert into SEQ_NPM_PACKVER values ( 1 );

create table SEQ_NPM_PACKVERRES (
    next_val bigint
) engine=InnoDB;

insert into SEQ_NPM_PACKVERRES values ( 1 );

create table SEQ_RES_REINDEX_JOB (
    next_val bigint
) engine=InnoDB;

insert into SEQ_RES_REINDEX_JOB values ( 1 );

create table SEQ_RESLINK_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_RESLINK_ID values ( 1 );

create table SEQ_RESOURCE_HISTORY_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_RESOURCE_HISTORY_ID values ( 1 );

create table SEQ_RESOURCE_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_RESOURCE_ID values ( 1 );

create table SEQ_RESPARMPRESENT_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_RESPARMPRESENT_ID values ( 1 );

create table SEQ_RESTAG_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_RESTAG_ID values ( 1 );

create table SEQ_SEARCH (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SEARCH values ( 1 );

create table SEQ_SEARCH_INC (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SEARCH_INC values ( 1 );

create table SEQ_SEARCH_RES (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SEARCH_RES values ( 1 );

create table SEQ_SPIDX_COORDS (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_COORDS values ( 1 );

create table SEQ_SPIDX_DATE (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_DATE values ( 1 );

create table SEQ_SPIDX_NUMBER (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_NUMBER values ( 1 );

create table SEQ_SPIDX_QUANTITY (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_QUANTITY values ( 1 );

create table SEQ_SPIDX_QUANTITY_NRML (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_QUANTITY_NRML values ( 1 );

create table SEQ_SPIDX_STRING (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_STRING values ( 1 );

create table SEQ_SPIDX_TOKEN (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_TOKEN values ( 1 );

create table SEQ_SPIDX_URI (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SPIDX_URI values ( 1 );

create table SEQ_SUBSCRIPTION_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_SUBSCRIPTION_ID values ( 1 );

create table SEQ_TAGDEF_ID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_TAGDEF_ID values ( 1 );

create table SEQ_VALUESET_C_DSGNTN_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_VALUESET_C_DSGNTN_PID values ( 1 );

create table SEQ_VALUESET_CONCEPT_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_VALUESET_CONCEPT_PID values ( 1 );

create table SEQ_VALUESET_PID (
    next_val bigint
) engine=InnoDB;

insert into SEQ_VALUESET_PID values ( 1 );

create table TRM_CODESYSTEM (
    PID bigint not null,
    CODE_SYSTEM_URI varchar(200) not null,
    CURRENT_VERSION_PID bigint,
    CS_NAME varchar(200),
    RES_ID bigint,
    primary key (PID)
) engine=InnoDB;

create table TRM_CODESYSTEM_VER (
    PID bigint not null,
    CS_DISPLAY varchar(200),
    CODESYSTEM_PID bigint,
    CS_VERSION_ID varchar(200),
    RES_ID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT (
    PID bigint not null,
    CODEVAL varchar(500) not null,
    CODESYSTEM_PID bigint not null,
    DISPLAY varchar(400),
    INDEX_STATUS bigint,
    PARENT_PIDS tinytext,
    PARENT_PIDS_VC longtext,
    CODE_SEQUENCE integer,
    CONCEPT_UPDATED datetime(6),
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_DESIG (
    PID bigint not null,
    LANG varchar(500),
    USE_CODE varchar(500),
    USE_DISPLAY varchar(500),
    USE_SYSTEM varchar(500),
    VAL varchar(2000),
    VAL_VC longtext,
    CS_VER_PID bigint,
    CONCEPT_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_MAP (
    PID bigint not null,
    RES_ID bigint,
    SOURCE_URL varchar(200),
    TARGET_URL varchar(200),
    URL varchar(200) not null,
    VER varchar(200),
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_MAP_GROUP (
    PID bigint not null,
    CONCEPT_MAP_URL varchar(200),
    SOURCE_URL varchar(200) not null,
    SOURCE_VS varchar(200),
    SOURCE_VERSION varchar(200),
    TARGET_URL varchar(200) not null,
    TARGET_VS varchar(200),
    TARGET_VERSION varchar(200),
    CONCEPT_MAP_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_MAP_GRP_ELEMENT (
    PID bigint not null,
    SOURCE_CODE varchar(500) not null,
    CONCEPT_MAP_URL varchar(200),
    SOURCE_DISPLAY varchar(500),
    SYSTEM_URL varchar(200),
    SYSTEM_VERSION varchar(200),
    VALUESET_URL varchar(200),
    CONCEPT_MAP_GROUP_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_MAP_GRP_ELM_TGT (
    PID bigint not null,
    TARGET_CODE varchar(500),
    CONCEPT_MAP_URL varchar(200),
    TARGET_DISPLAY varchar(500),
    TARGET_EQUIVALENCE enum ('RELATEDTO','EQUIVALENT','EQUAL','WIDER','SUBSUMES','NARROWER','SPECIALIZES','INEXACT','UNMATCHED','DISJOINT','NULL'),
    SYSTEM_URL varchar(200),
    SYSTEM_VERSION varchar(200),
    VALUESET_URL varchar(200),
    CONCEPT_MAP_GRP_ELM_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_PC_LINK (
    PID bigint not null,
    CHILD_PID bigint,
    CODESYSTEM_PID bigint not null,
    PARENT_PID bigint,
    REL_TYPE integer,
    primary key (PID)
) engine=InnoDB;

create table TRM_CONCEPT_PROPERTY (
    PID bigint not null,
    PROP_CODESYSTEM varchar(500),
    PROP_DISPLAY varchar(500),
    PROP_KEY varchar(500) not null,
    PROP_TYPE integer not null,
    PROP_VAL varchar(500),
    PROP_VAL_BIN longblob,
    PROP_VAL_LOB tinyblob,
    CS_VER_PID bigint,
    CONCEPT_PID bigint,
    primary key (PID)
) engine=InnoDB;

create table TRM_VALUESET (
    PID bigint not null,
    EXPANSION_STATUS enum ('NOT_EXPANDED','EXPANSION_IN_PROGRESS','EXPANDED','FAILED_TO_EXPAND') not null,
    EXPANDED_AT datetime(6),
    VSNAME varchar(200),
    RES_ID bigint,
    TOTAL_CONCEPT_DESIGNATIONS bigint default 0 not null,
    TOTAL_CONCEPTS bigint default 0 not null,
    URL varchar(200) not null,
    VER varchar(200),
    primary key (PID)
) engine=InnoDB;

create table TRM_VALUESET_C_DESIGNATION (
    PID bigint not null,
    VALUESET_CONCEPT_PID bigint not null,
    LANG varchar(500),
    USE_CODE varchar(500),
    USE_DISPLAY varchar(500),
    USE_SYSTEM varchar(500),
    VAL varchar(2000) not null,
    VALUESET_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create table TRM_VALUESET_CONCEPT (
    PID bigint not null,
    CODEVAL varchar(500) not null,
    DISPLAY varchar(400),
    INDEX_STATUS bigint,
    VALUESET_ORDER integer not null,
    SOURCE_DIRECT_PARENT_PIDS tinytext,
    SOURCE_DIRECT_PARENT_PIDS_VC longtext,
    SOURCE_PID bigint,
    SYSTEM_URL varchar(200) not null,
    SYSTEM_VER varchar(200),
    VALUESET_PID bigint not null,
    primary key (PID)
) engine=InnoDB;

create index IDX_BT2JI_CT 
   on BT2_JOB_INSTANCE (CREATE_TIME);

create index IDX_BT2WC_II_SEQ 
   on BT2_WORK_CHUNK (INSTANCE_ID, SEQ);

create index IDX_BT2WC_II_SI_S_SEQ_ID 
   on BT2_WORK_CHUNK (INSTANCE_ID, TGT_STEP_ID, STAT, SEQ, ID);

create index IDX_CDH_LB_REF_RULE_SUBS 
   on CDH_LB_REF (RULE_SYSTEM, RULE_VALUE, SUBS_RES_ID);

create index IDX_CDH_LB_REF_TRACK_PARAM 
   on CDH_LB_REF (TRACK_PARAM);

create index IDX_CDH_LB_REF_TRACK_SUBPARAM 
   on CDH_LB_REF (TRACK_SUBPARAM);

create index IDX_CDH_LB_REF_EXPIRES 
   on CDH_LB_REF (EXPIRES);

create index FK_LB_RES 
   on CDH_LB_REF (LB_RES_ID);

create index FK_LB_SUBS 
   on CDH_LB_REF (SUBS_RES_ID);

create index FK_LB_ROOT 
   on CDH_LB_REF (ROOT_RES_ID);

alter table CDH_LB_REF 
   add constraint IDX_CDH_LB_REF_UNIQ unique (RULE_SYSTEM, RULE_VALUE, ROOT_RES_ID, SUBS_RES_ID, LB_RES_ID);

create index IDX_CDH_LB_SUB_GROUP_GROUP 
   on CDH_LB_SUB_GROUP (SUBS_GROUP);

create index IDX_CDH_LB_SUB_GROUP_ID 
   on CDH_LB_SUB_GROUP (SUBS_ID);

alter table CDH_LB_SUB_GROUP 
   add constraint IDX_CDH_LB_SUB_ID_GROUP unique (SUBS_RES_ID, SUBS_GROUP);

alter table CDH_LB_WL 
   add constraint IDX_CDH_LB_WL_WATCHLIST_TOKEN unique (WATCHLIST_SYSTEM, WATCHLIST_VALUE);

create index FK_LB_WL_SUBS 
   on CDH_LB_WL_SUBS (SUBS_RES_ID);

alter table CDH_LB_WL_SUBS 
   add constraint IDX_CDH_LB_WL_SUBS_WATCHLIST unique (WATCHLIST_ID, SUBS_RES_ID);

create index IDX_BLKEX_EXPTIME 
   on HFJ_BLK_EXPORT_JOB (EXP_TIME);

alter table HFJ_BLK_EXPORT_JOB 
   add constraint IDX_BLKEX_JOB_ID unique (JOB_ID);

alter table HFJ_BLK_IMPORT_JOB 
   add constraint IDX_BLKIM_JOB_ID unique (JOB_ID);

create index IDX_BLKIM_JOBFILE_JOBID 
   on HFJ_BLK_IMPORT_JOBFILE (JOB_PID);

create index IDX_RESHISTTAG_RESID 
   on HFJ_HISTORY_TAG (RES_ID);

alter table HFJ_HISTORY_TAG 
   add constraint IDX_RESHISTTAG_TAGID unique (RES_VER_PID, TAG_ID);

create index IDX_IDXCMBTOKNU_STR 
   on HFJ_IDX_CMB_TOK_NU (IDX_STRING);

create index IDX_IDXCMBTOKNU_HASHC 
   on HFJ_IDX_CMB_TOK_NU (HASH_COMPLETE, RES_ID, PARTITION_ID);

create index IDX_IDXCMBTOKNU_RES 
   on HFJ_IDX_CMB_TOK_NU (RES_ID);

create index IDX_IDXCMPSTRUNIQ_RESOURCE 
   on HFJ_IDX_CMP_STRING_UNIQ (RES_ID);

alter table HFJ_IDX_CMP_STRING_UNIQ 
   add constraint IDX_IDXCMPSTRUNIQ_STRING unique (IDX_STRING);

alter table HFJ_PARTITION 
   add constraint IDX_PART_NAME unique (PART_NAME);

create index IDX_RL_SRC 
   on HFJ_RES_LINK (SRC_RESOURCE_ID);

create index IDX_RL_TGT_v2 
   on HFJ_RES_LINK (TARGET_RESOURCE_ID, SRC_PATH, SRC_RESOURCE_ID, TARGET_RESOURCE_TYPE, PARTITION_ID);

create index IDX_RESPARMPRESENT_RESID 
   on HFJ_RES_PARAM_PRESENT (RES_ID);

create index IDX_RESPARMPRESENT_HASHPRES 
   on HFJ_RES_PARAM_PRESENT (HASH_PRESENCE);

create index IDX_RESSEARCHURL_RES 
   on HFJ_RES_SEARCH_URL (RES_ID);

create index IDX_RESSEARCHURL_TIME 
   on HFJ_RES_SEARCH_URL (CREATED_TIME);

create index IDX_RES_TAG_RES_TAG 
   on HFJ_RES_TAG (RES_ID, TAG_ID, PARTITION_ID);

create index IDX_RES_TAG_TAG_RES 
   on HFJ_RES_TAG (TAG_ID, RES_ID, PARTITION_ID);

alter table HFJ_RES_TAG 
   add constraint IDX_RESTAG_TAGID unique (RES_ID, TAG_ID);

create index IDX_RESVER_TYPE_DATE 
   on HFJ_RES_VER (RES_TYPE, RES_UPDATED, RES_ID);

create index IDX_RESVER_ID_DATE 
   on HFJ_RES_VER (RES_ID, RES_UPDATED);

create index IDX_RESVER_DATE 
   on HFJ_RES_VER (RES_UPDATED, RES_ID);

alter table HFJ_RES_VER 
   add constraint IDX_RESVER_ID_VER unique (RES_ID, RES_VER);

create index IDX_RESVERPROV_SOURCEURI 
   on HFJ_RES_VER_PROV (SOURCE_URI);

create index IDX_RESVERPROV_REQUESTID 
   on HFJ_RES_VER_PROV (REQUEST_ID);

create index IDX_RESVERPROV_RES_PID 
   on HFJ_RES_VER_PROV (RES_PID);

create index IDX_RES_DATE 
   on HFJ_RESOURCE (RES_UPDATED);

create index IDX_RES_FHIR_ID 
   on HFJ_RESOURCE (FHIR_ID);

create index IDX_RES_TYPE_DEL_UPDATED 
   on HFJ_RESOURCE (RES_TYPE, RES_DELETED_AT, RES_UPDATED, PARTITION_ID, RES_ID);

create index IDX_RES_RESID_UPDATED 
   on HFJ_RESOURCE (RES_ID, RES_UPDATED, PARTITION_ID);

alter table HFJ_RESOURCE 
   add constraint IDX_RES_TYPE_FHIR_ID unique (RES_TYPE, FHIR_ID);

create index IDX_SEARCH_RESTYPE_HASHS 
   on HFJ_SEARCH (RESOURCE_TYPE, SEARCH_QUERY_STRING_HASH, CREATED);

create index IDX_SEARCH_CREATED 
   on HFJ_SEARCH (CREATED);

alter table HFJ_SEARCH 
   add constraint IDX_SEARCH_UUID unique (SEARCH_UUID);

create index FK_SEARCHINC_SEARCH 
   on HFJ_SEARCH_INCLUDE (SEARCH_PID);

alter table HFJ_SEARCH_RESULT 
   add constraint IDX_SEARCHRES_ORDER unique (SEARCH_PID, SEARCH_ORDER);

create index IDX_SP_COORDS_HASH_V2 
   on HFJ_SPIDX_COORDS (HASH_IDENTITY, SP_LATITUDE, SP_LONGITUDE, RES_ID, PARTITION_ID);

create index IDX_SP_COORDS_UPDATED 
   on HFJ_SPIDX_COORDS (SP_UPDATED);

create index IDX_SP_COORDS_RESID 
   on HFJ_SPIDX_COORDS (RES_ID);

create index IDX_SP_DATE_HASH_V2 
   on HFJ_SPIDX_DATE (HASH_IDENTITY, SP_VALUE_LOW, SP_VALUE_HIGH, RES_ID, PARTITION_ID);

create index IDX_SP_DATE_HASH_HIGH_V2 
   on HFJ_SPIDX_DATE (HASH_IDENTITY, SP_VALUE_HIGH, RES_ID, PARTITION_ID);

create index IDX_SP_DATE_ORD_HASH_V2 
   on HFJ_SPIDX_DATE (HASH_IDENTITY, SP_VALUE_LOW_DATE_ORDINAL, SP_VALUE_HIGH_DATE_ORDINAL, RES_ID, PARTITION_ID);

create index IDX_SP_DATE_ORD_HASH_HIGH_V2 
   on HFJ_SPIDX_DATE (HASH_IDENTITY, SP_VALUE_HIGH_DATE_ORDINAL, RES_ID, PARTITION_ID);

create index IDX_SP_DATE_RESID_V2 
   on HFJ_SPIDX_DATE (RES_ID, HASH_IDENTITY, SP_VALUE_LOW, SP_VALUE_HIGH, SP_VALUE_LOW_DATE_ORDINAL, SP_VALUE_HIGH_DATE_ORDINAL, PARTITION_ID);

create index IDX_SP_NUMBER_HASH_VAL_V2 
   on HFJ_SPIDX_NUMBER (HASH_IDENTITY, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_NUMBER_RESID_V2 
   on HFJ_SPIDX_NUMBER (RES_ID, HASH_IDENTITY, SP_VALUE, PARTITION_ID);

create index IDX_SP_QUANTITY_HASH_V2 
   on HFJ_SPIDX_QUANTITY (HASH_IDENTITY, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_QUANTITY_HASH_UN_V2 
   on HFJ_SPIDX_QUANTITY (HASH_IDENTITY_AND_UNITS, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_QUANTITY_HASH_SYSUN_V2 
   on HFJ_SPIDX_QUANTITY (HASH_IDENTITY_SYS_UNITS, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_QUANTITY_RESID_V2 
   on HFJ_SPIDX_QUANTITY (RES_ID, HASH_IDENTITY, HASH_IDENTITY_SYS_UNITS, HASH_IDENTITY_AND_UNITS, SP_VALUE, PARTITION_ID);

create index IDX_SP_QNTY_NRML_HASH_V2 
   on HFJ_SPIDX_QUANTITY_NRML (HASH_IDENTITY, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_QNTY_NRML_HASH_UN_V2 
   on HFJ_SPIDX_QUANTITY_NRML (HASH_IDENTITY_AND_UNITS, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_QNTY_NRML_HASH_SYSUN_V2 
   on HFJ_SPIDX_QUANTITY_NRML (HASH_IDENTITY_SYS_UNITS, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_QNTY_NRML_RESID_V2 
   on HFJ_SPIDX_QUANTITY_NRML (RES_ID, HASH_IDENTITY, HASH_IDENTITY_SYS_UNITS, HASH_IDENTITY_AND_UNITS, SP_VALUE, PARTITION_ID);

create index IDX_SP_STRING_HASH_IDENT_V2 
   on HFJ_SPIDX_STRING (HASH_IDENTITY, RES_ID, PARTITION_ID);

create index IDX_SP_STRING_HASH_NRM_V2 
   on HFJ_SPIDX_STRING (HASH_NORM_PREFIX, SP_VALUE_NORMALIZED, RES_ID, PARTITION_ID);

create index IDX_SP_STRING_HASH_EXCT_V2 
   on HFJ_SPIDX_STRING (HASH_EXACT, RES_ID, PARTITION_ID);

create index IDX_SP_STRING_RESID_V2 
   on HFJ_SPIDX_STRING (RES_ID, HASH_NORM_PREFIX, PARTITION_ID);

create index IDX_SP_TOKEN_HASH_V2 
   on HFJ_SPIDX_TOKEN (HASH_IDENTITY, SP_SYSTEM, SP_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_TOKEN_HASH_S_V2 
   on HFJ_SPIDX_TOKEN (HASH_SYS, RES_ID, PARTITION_ID);

create index IDX_SP_TOKEN_HASH_SV_V2 
   on HFJ_SPIDX_TOKEN (HASH_SYS_AND_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_TOKEN_HASH_V_V2 
   on HFJ_SPIDX_TOKEN (HASH_VALUE, RES_ID, PARTITION_ID);

create index IDX_SP_TOKEN_RESID_V2 
   on HFJ_SPIDX_TOKEN (RES_ID, HASH_SYS_AND_VALUE, HASH_VALUE, HASH_SYS, HASH_IDENTITY, PARTITION_ID);

create index IDX_SP_URI_HASH_URI_V2 
   on HFJ_SPIDX_URI (HASH_URI, RES_ID, PARTITION_ID);

create index IDX_SP_URI_HASH_IDENTITY_V2 
   on HFJ_SPIDX_URI (HASH_IDENTITY, SP_URI, RES_ID, PARTITION_ID);

create index IDX_SP_URI_COORDS 
   on HFJ_SPIDX_URI (RES_ID);

alter table HFJ_SUBSCRIPTION_STATS 
   add constraint IDX_SUBSC_RESID unique (RES_ID);

create index IDX_TAG_DEF_TP_CD_SYS 
   on HFJ_TAG_DEF (TAG_TYPE, TAG_CODE, TAG_SYSTEM, TAG_ID, TAG_VERSION, TAG_USER_SELECTED);

create index IDX_EMPI_MATCH_TGT_VER 
   on MPI_LINK (MATCH_RESULT, TARGET_PID, VERSION);

create index IDX_EMPI_GR_TGT 
   on MPI_LINK (GOLDEN_RESOURCE_PID, TARGET_PID);

create index FK_EMPI_LINK_TARGET 
   on MPI_LINK (TARGET_PID);

create index IDX_EMPI_TGT_MR_LS 
   on MPI_LINK (TARGET_TYPE, MATCH_RESULT, LINK_SOURCE);

create index IDX_EMPI_TGT_MR_SCORE 
   on MPI_LINK (TARGET_TYPE, MATCH_RESULT, SCORE);

alter table MPI_LINK 
   add constraint IDX_EMPI_PERSON_TGT unique (PERSON_PID, TARGET_PID);

alter table NPM_PACKAGE 
   add constraint IDX_PACK_ID unique (PACKAGE_ID);

create index FK_NPM_PKV_PKG 
   on NPM_PACKAGE_VER (PACKAGE_PID);

create index FK_NPM_PKV_RESID 
   on NPM_PACKAGE_VER (BINARY_RES_ID);

alter table NPM_PACKAGE_VER 
   add constraint IDX_PACKVER unique (PACKAGE_ID, VERSION_ID);

create index IDX_PACKVERRES_URL 
   on NPM_PACKAGE_VER_RES (CANONICAL_URL);

create index FK_NPM_PACKVERRES_PACKVER 
   on NPM_PACKAGE_VER_RES (PACKVER_PID);

create index FK_NPM_PKVR_RESID 
   on NPM_PACKAGE_VER_RES (BINARY_RES_ID);

create index FK_TRMCODESYSTEM_RES 
   on TRM_CODESYSTEM (RES_ID);

create index FK_TRMCODESYSTEM_CURVER 
   on TRM_CODESYSTEM (CURRENT_VERSION_PID);

alter table TRM_CODESYSTEM 
   add constraint IDX_CS_CODESYSTEM unique (CODE_SYSTEM_URI);

create index FK_CODESYSVER_RES_ID 
   on TRM_CODESYSTEM_VER (RES_ID);

create index FK_CODESYSVER_CS_ID 
   on TRM_CODESYSTEM_VER (CODESYSTEM_PID);

alter table TRM_CODESYSTEM_VER 
   add constraint IDX_CODESYSTEM_AND_VER unique (CODESYSTEM_PID, CS_VERSION_ID);

create index IDX_CONCEPT_INDEXSTATUS 
   on TRM_CONCEPT (INDEX_STATUS);

create index IDX_CONCEPT_UPDATED 
   on TRM_CONCEPT (CONCEPT_UPDATED);

alter table TRM_CONCEPT 
   add constraint IDX_CONCEPT_CS_CODE unique (CODESYSTEM_PID, CODEVAL);

create index FK_CONCEPTDESIG_CONCEPT 
   on TRM_CONCEPT_DESIG (CONCEPT_PID);

create index FK_CONCEPTDESIG_CSV 
   on TRM_CONCEPT_DESIG (CS_VER_PID);

create index FK_TRMCONCEPTMAP_RES 
   on TRM_CONCEPT_MAP (RES_ID);

alter table TRM_CONCEPT_MAP 
   add constraint IDX_CONCEPT_MAP_URL unique (URL, VER);

create index FK_TCMGROUP_CONCEPTMAP 
   on TRM_CONCEPT_MAP_GROUP (CONCEPT_MAP_PID);

create index IDX_CNCPT_MAP_GRP_CD 
   on TRM_CONCEPT_MAP_GRP_ELEMENT (SOURCE_CODE);

create index FK_TCMGELEMENT_GROUP 
   on TRM_CONCEPT_MAP_GRP_ELEMENT (CONCEPT_MAP_GROUP_PID);

create index IDX_CNCPT_MP_GRP_ELM_TGT_CD 
   on TRM_CONCEPT_MAP_GRP_ELM_TGT (TARGET_CODE);

create index FK_TCMGETARGET_ELEMENT 
   on TRM_CONCEPT_MAP_GRP_ELM_TGT (CONCEPT_MAP_GRP_ELM_PID);

create index FK_TERM_CONCEPTPC_CHILD 
   on TRM_CONCEPT_PC_LINK (CHILD_PID);

create index FK_TERM_CONCEPTPC_PARENT 
   on TRM_CONCEPT_PC_LINK (PARENT_PID);

create index FK_TERM_CONCEPTPC_CS 
   on TRM_CONCEPT_PC_LINK (CODESYSTEM_PID);

create index FK_CONCEPTPROP_CONCEPT 
   on TRM_CONCEPT_PROPERTY (CONCEPT_PID);

create index FK_CONCEPTPROP_CSV 
   on TRM_CONCEPT_PROPERTY (CS_VER_PID);

create index FK_TRMVALUESET_RES 
   on TRM_VALUESET (RES_ID);

alter table TRM_VALUESET 
   add constraint IDX_VALUESET_URL unique (URL, VER);

create index FK_TRM_VALUESET_CONCEPT_PID 
   on TRM_VALUESET_C_DESIGNATION (VALUESET_CONCEPT_PID);

create index FK_TRM_VSCD_VS_PID 
   on TRM_VALUESET_C_DESIGNATION (VALUESET_PID);

alter table TRM_VALUESET_CONCEPT 
   add constraint IDX_VS_CONCEPT_CSCD unique (VALUESET_PID, SYSTEM_URL, CODEVAL);

alter table TRM_VALUESET_CONCEPT 
   add constraint IDX_VS_CONCEPT_ORDER unique (VALUESET_PID, VALUESET_ORDER);

alter table BT2_WORK_CHUNK 
   add constraint FK_BT2WC_INSTANCE 
   foreign key (INSTANCE_ID) 
   references BT2_JOB_INSTANCE (ID);

alter table CDH_LB_REF 
   add constraint FK_LB_RES 
   foreign key (LB_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table CDH_LB_REF 
   add constraint FK_LB_ROOT 
   foreign key (ROOT_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table CDH_LB_REF 
   add constraint FK_LB_SUBS 
   foreign key (SUBS_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table CDH_LB_SUB_GROUP 
   add constraint FK_LB_GP_SUBS 
   foreign key (SUBS_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table CDH_LB_WL_SUBS 
   add constraint FK_LB_WL_SUBS 
   foreign key (SUBS_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table CDH_LB_WL_SUBS 
   add constraint FK_LB_WL_ID 
   foreign key (WATCHLIST_ID) 
   references CDH_LB_WL (PID);

alter table HFJ_BLK_EXPORT_COLFILE 
   add constraint FK_BLKEXCOLFILE_COLLECT 
   foreign key (COLLECTION_PID) 
   references HFJ_BLK_EXPORT_COLLECTION (PID);

alter table HFJ_BLK_EXPORT_COLLECTION 
   add constraint FK_BLKEXCOL_JOB 
   foreign key (JOB_PID) 
   references HFJ_BLK_EXPORT_JOB (PID);

alter table HFJ_BLK_IMPORT_JOBFILE 
   add constraint FK_BLKIMJOBFILE_JOB 
   foreign key (JOB_PID) 
   references HFJ_BLK_IMPORT_JOB (PID);

alter table HFJ_HISTORY_TAG 
   add constraint FKtderym7awj6q8iq5c51xv4ndw 
   foreign key (TAG_ID) 
   references HFJ_TAG_DEF (TAG_ID);

alter table HFJ_HISTORY_TAG 
   add constraint FK_HISTORYTAG_HISTORY 
   foreign key (RES_VER_PID) 
   references HFJ_RES_VER (PID);

alter table HFJ_IDX_CMB_TOK_NU 
   add constraint FK_IDXCMBTOKNU_RES_ID 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_IDX_CMP_STRING_UNIQ 
   add constraint FK_IDXCMPSTRUNIQ_RES_ID 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_LINK 
   add constraint FK_RESLINK_SOURCE 
   foreign key (SRC_RESOURCE_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_LINK 
   add constraint FK_RESLINK_TARGET 
   foreign key (TARGET_RESOURCE_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_PARAM_PRESENT 
   add constraint FK_RESPARMPRES_RESID 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_SEARCH_URL 
   add constraint FK_RES_SEARCH_URL_RESOURCE 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_TAG 
   add constraint FKbfcjbaftmiwr3rxkwsy23vneo 
   foreign key (TAG_ID) 
   references HFJ_TAG_DEF (TAG_ID);

alter table HFJ_RES_TAG 
   add constraint FK_RESTAG_RESOURCE 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_VER 
   add constraint FK_RESOURCE_HISTORY_RESOURCE 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_VER_PROV 
   add constraint FK_RESVERPROV_RES_PID 
   foreign key (RES_PID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_RES_VER_PROV 
   add constraint FK_RESVERPROV_RESVER_PID 
   foreign key (RES_VER_PID) 
   references HFJ_RES_VER (PID);

alter table HFJ_SEARCH_INCLUDE 
   add constraint FK_SEARCHINC_SEARCH 
   foreign key (SEARCH_PID) 
   references HFJ_SEARCH (PID);

alter table HFJ_SPIDX_COORDS 
   add constraint FKC97MPK37OKWU8QVTCEG2NH9VN 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_DATE 
   add constraint FK_SP_DATE_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_NUMBER 
   add constraint FK_SP_NUMBER_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_QUANTITY 
   add constraint FK_SP_QUANTITY_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_QUANTITY_NRML 
   add constraint FK_SP_QUANTITYNM_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_STRING 
   add constraint FK_SPIDXSTR_RESOURCE 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_TOKEN 
   add constraint FK_SP_TOKEN_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SPIDX_URI 
   add constraint FKGXSREUTYMMFJUWDSWV3Y887DO 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table HFJ_SUBSCRIPTION_STATS 
   add constraint FK_SUBSC_RESOURCE_ID 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table MPI_LINK 
   add constraint FK_EMPI_LINK_GOLDEN_RESOURCE 
   foreign key (GOLDEN_RESOURCE_PID) 
   references HFJ_RESOURCE (RES_ID);

alter table MPI_LINK 
   add constraint FK_EMPI_LINK_PERSON 
   foreign key (PERSON_PID) 
   references HFJ_RESOURCE (RES_ID);

alter table MPI_LINK 
   add constraint FK_EMPI_LINK_TARGET 
   foreign key (TARGET_PID) 
   references HFJ_RESOURCE (RES_ID);

alter table MPI_LINK_AUD 
   add constraint FKaow7nxncloec419ars0fpp58m 
   foreign key (REV) 
   references HFJ_REVINFO (REV);

alter table NPM_PACKAGE_VER 
   add constraint FK_NPM_PKV_PKG 
   foreign key (PACKAGE_PID) 
   references NPM_PACKAGE (PID);

alter table NPM_PACKAGE_VER 
   add constraint FK_NPM_PKV_RESID 
   foreign key (BINARY_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table NPM_PACKAGE_VER_RES 
   add constraint FK_NPM_PACKVERRES_PACKVER 
   foreign key (PACKVER_PID) 
   references NPM_PACKAGE_VER (PID);

alter table NPM_PACKAGE_VER_RES 
   add constraint FK_NPM_PKVR_RESID 
   foreign key (BINARY_RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table TRM_CODESYSTEM 
   add constraint FK_TRMCODESYSTEM_CURVER 
   foreign key (CURRENT_VERSION_PID) 
   references TRM_CODESYSTEM_VER (PID);

alter table TRM_CODESYSTEM 
   add constraint FK_TRMCODESYSTEM_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table TRM_CODESYSTEM_VER 
   add constraint FK_CODESYSVER_CS_ID 
   foreign key (CODESYSTEM_PID) 
   references TRM_CODESYSTEM (PID);

alter table TRM_CODESYSTEM_VER 
   add constraint FK_CODESYSVER_RES_ID 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table TRM_CONCEPT 
   add constraint FK_CONCEPT_PID_CS_PID 
   foreign key (CODESYSTEM_PID) 
   references TRM_CODESYSTEM_VER (PID);

alter table TRM_CONCEPT_DESIG 
   add constraint FK_CONCEPTDESIG_CSV 
   foreign key (CS_VER_PID) 
   references TRM_CODESYSTEM_VER (PID);

alter table TRM_CONCEPT_DESIG 
   add constraint FK_CONCEPTDESIG_CONCEPT 
   foreign key (CONCEPT_PID) 
   references TRM_CONCEPT (PID);

alter table TRM_CONCEPT_MAP 
   add constraint FK_TRMCONCEPTMAP_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table TRM_CONCEPT_MAP_GROUP 
   add constraint FK_TCMGROUP_CONCEPTMAP 
   foreign key (CONCEPT_MAP_PID) 
   references TRM_CONCEPT_MAP (PID);

alter table TRM_CONCEPT_MAP_GRP_ELEMENT 
   add constraint FK_TCMGELEMENT_GROUP 
   foreign key (CONCEPT_MAP_GROUP_PID) 
   references TRM_CONCEPT_MAP_GROUP (PID);

alter table TRM_CONCEPT_MAP_GRP_ELM_TGT 
   add constraint FK_TCMGETARGET_ELEMENT 
   foreign key (CONCEPT_MAP_GRP_ELM_PID) 
   references TRM_CONCEPT_MAP_GRP_ELEMENT (PID);

alter table TRM_CONCEPT_PC_LINK 
   add constraint FK_TERM_CONCEPTPC_CHILD 
   foreign key (CHILD_PID) 
   references TRM_CONCEPT (PID);

alter table TRM_CONCEPT_PC_LINK 
   add constraint FK_TERM_CONCEPTPC_CS 
   foreign key (CODESYSTEM_PID) 
   references TRM_CODESYSTEM_VER (PID);

alter table TRM_CONCEPT_PC_LINK 
   add constraint FK_TERM_CONCEPTPC_PARENT 
   foreign key (PARENT_PID) 
   references TRM_CONCEPT (PID);

alter table TRM_CONCEPT_PROPERTY 
   add constraint FK_CONCEPTPROP_CSV 
   foreign key (CS_VER_PID) 
   references TRM_CODESYSTEM_VER (PID);

alter table TRM_CONCEPT_PROPERTY 
   add constraint FK_CONCEPTPROP_CONCEPT 
   foreign key (CONCEPT_PID) 
   references TRM_CONCEPT (PID);

alter table TRM_VALUESET 
   add constraint FK_TRMVALUESET_RES 
   foreign key (RES_ID) 
   references HFJ_RESOURCE (RES_ID);

alter table TRM_VALUESET_C_DESIGNATION 
   add constraint FK_TRM_VALUESET_CONCEPT_PID 
   foreign key (VALUESET_CONCEPT_PID) 
   references TRM_VALUESET_CONCEPT (PID);

alter table TRM_VALUESET_C_DESIGNATION 
   add constraint FK_TRM_VSCD_VS_PID 
   foreign key (VALUESET_PID) 
   references TRM_VALUESET (PID);

alter table TRM_VALUESET_CONCEPT 
   add constraint FK_TRM_VALUESET_PID 
   foreign key (VALUESET_PID) 
   references TRM_VALUESET (PID);