-- MySQL Database Dump
-- Converted from MSSQL
USE `LRS43`;

SET FOREIGN_KEY_CHECKS=0;

-- Database Schema Dump
-- Database: LRS43
-- Generated: 2025-11-13T18:51:55.283552
-- ==========================================

-- Total Tables: 168

-- ==========================================
-- Table: alf_access_control_entry
-- Created: 2014-11-25 03:45:38.063000
-- Modified: 2014-11-25 03:45:38.080000
-- ==========================================

CREATE TABLE alf_access_control_entry (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `permission_id` DECIMAL(19,0) NOT NULL,
    `authority_id` DECIMAL(19,0) NOT NULL,
    `allowed` TINYINT NOT NULL,
    `applies` INT NOT NULL,
    `context_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_access_control_entry
    ADD CONSTRAINT `PK__alf_acce__3213E83F08DA1597` PRIMARY KEY (id);

CREATE INDEX `fk_alf_ace_auth` ON alf_access_control_entry (authority_id);
CREATE INDEX `fk_alf_ace_ctx` ON alf_access_control_entry (context_id);
CREATE INDEX `fk_alf_ace_perm` ON alf_access_control_entry (permission_id);
CREATE UNIQUE INDEX `permission_id` ON alf_access_control_entry (permission_id, authority_id, allowed, applies);


-- ==========================================
-- Table: alf_access_control_list
-- Created: 2014-11-25 03:45:38.073000
-- Modified: 2014-11-25 03:45:38.433000
-- ==========================================

CREATE TABLE alf_access_control_list (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `acl_id` VARCHAR(36) NOT NULL,
    `latest` TINYINT NOT NULL,
    `acl_version` DECIMAL(19,0) NOT NULL,
    `inherits` TINYINT NOT NULL,
    `inherits_from` DECIMAL(19,0) NULL,
    `type` INT NOT NULL,
    `inherited_acl` DECIMAL(19,0) NULL,
    `is_versioned` TINYINT NOT NULL,
    `requires_version` TINYINT NOT NULL,
    `acl_change_set` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_access_control_list
    ADD CONSTRAINT `PK__alf_acce__3213E83FED23F4AC` PRIMARY KEY (id);

CREATE UNIQUE INDEX `acl_id` ON alf_access_control_list (acl_id, latest, acl_version);
CREATE INDEX `fk_alf_acl_acs` ON alf_access_control_list (acl_change_set);
CREATE INDEX `idx_alf_acl_inh` ON alf_access_control_list (inherits, inherits_from);


-- ==========================================
-- Table: alf_ace_context
-- Created: 2014-11-25 03:45:38.057000
-- Modified: 2014-11-25 03:45:38.067000
-- ==========================================

CREATE TABLE alf_ace_context (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `class_context` VARCHAR(1024) NULL,
    `property_context` VARCHAR(1024) NULL,
    `kvp_context` VARCHAR(1024) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_ace_context
    ADD CONSTRAINT `PK__alf_ace___3213E83FBAB7EA8F` PRIMARY KEY (id);


-- ==========================================
-- Table: alf_acl_change_set
-- Created: 2014-11-25 03:45:38.070000
-- Modified: 2014-11-25 03:45:38.073000
-- ==========================================

CREATE TABLE alf_acl_change_set (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_acl_change_set
    ADD CONSTRAINT `PK__alf_acl___3213E83F82F2803F` PRIMARY KEY (id);


-- ==========================================
-- Table: alf_acl_member
-- Created: 2014-11-25 03:45:38.080000
-- Modified: 2014-11-25 03:45:38.090000
-- ==========================================

CREATE TABLE alf_acl_member (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `acl_id` DECIMAL(19,0) NOT NULL,
    `ace_id` DECIMAL(19,0) NOT NULL,
    `pos` INT NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_acl_member
    ADD CONSTRAINT `PK__alf_acl___3213E83F98115AF8` PRIMARY KEY (id);

CREATE UNIQUE INDEX `aclm_acl_id` ON alf_acl_member (acl_id, ace_id, pos);
CREATE INDEX `fk_alf_aclm_ace` ON alf_acl_member (ace_id);
CREATE INDEX `fk_alf_aclm_acl` ON alf_acl_member (acl_id);


-- ==========================================
-- Table: alf_activity_feed
-- Created: 2014-11-25 03:45:38.463000
-- Modified: 2014-11-25 03:45:38.480000
-- ==========================================

CREATE TABLE alf_activity_feed (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `post_id` DECIMAL(19,0) NULL,
    `post_date` DATETIME NOT NULL,
    `activity_summary` VARCHAR(1024) NULL,
    `feed_user_id` VARCHAR(255) NULL,
    `activity_type` VARCHAR(255) NOT NULL,
    `activity_format` VARCHAR(10) NULL,
    `site_network` VARCHAR(255) NULL,
    `app_tool` VARCHAR(36) NULL,
    `post_user_id` VARCHAR(255) NOT NULL,
    `feed_date` DATETIME NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_activity_feed
    ADD CONSTRAINT `PK__alf_acti__3213E83FF6E40892` PRIMARY KEY (id);

CREATE INDEX `feed_activityformat_idx` ON alf_activity_feed (activity_format);
CREATE INDEX `feed_feeduserid_idx` ON alf_activity_feed (feed_user_id);
CREATE INDEX `feed_postdate_idx` ON alf_activity_feed (post_date);
CREATE INDEX `feed_postuserid_idx` ON alf_activity_feed (post_user_id);
CREATE INDEX `feed_sitenetwork_idx` ON alf_activity_feed (site_network);


-- ==========================================
-- Table: alf_activity_feed_control
-- Created: 2014-11-25 03:45:38.473000
-- Modified: 2014-11-25 03:45:38.477000
-- ==========================================

CREATE TABLE alf_activity_feed_control (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `feed_user_id` VARCHAR(255) NOT NULL,
    `site_network` VARCHAR(255) NULL,
    `app_tool` VARCHAR(36) NULL,
    `last_modified` DATETIME NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_activity_feed_control
    ADD CONSTRAINT `PK__alf_acti__3213E83FA6D2E120` PRIMARY KEY (id);

CREATE INDEX `feedctrl_feeduserid_idx` ON alf_activity_feed_control (feed_user_id);


-- ==========================================
-- Table: alf_activity_post
-- Created: 2014-11-25 03:45:38.477000
-- Modified: 2014-11-25 03:45:38.483000
-- ==========================================

CREATE TABLE alf_activity_post (
    `sequence_id` BIGINT AUTO_INCREMENT NOT NULL,
    `post_date` DATETIME NOT NULL,
    `status` VARCHAR(10) NOT NULL,
    `activity_data` VARCHAR(1024) NOT NULL,
    `post_user_id` VARCHAR(255) NOT NULL,
    `job_task_node` INT NOT NULL,
    `site_network` VARCHAR(255) NULL,
    `app_tool` VARCHAR(36) NULL,
    `activity_type` VARCHAR(255) NOT NULL,
    `last_modified` DATETIME NOT NULL,
    PRIMARY KEY (`sequence_id`)
);

ALTER TABLE alf_activity_post
    ADD CONSTRAINT `PK__alf_acti__B2649B241E8E74C3` PRIMARY KEY (sequence_id);

CREATE INDEX `post_jobtasknode_idx` ON alf_activity_post (job_task_node);
CREATE INDEX `post_status_idx` ON alf_activity_post (status);


-- ==========================================
-- Table: alf_applied_patch
-- Created: 2014-11-25 03:45:38.040000
-- Modified: 2014-11-25 03:45:38.040000
-- ==========================================

CREATE TABLE alf_applied_patch (
    `id` VARCHAR(64) NOT NULL,
    `description` VARCHAR(1024) NULL,
    `fixes_from_schema` INT NULL,
    `fixes_to_schema` INT NULL,
    `applied_to_schema` INT NULL,
    `target_schema` INT NULL,
    `applied_on_date` DATETIME NULL,
    `applied_to_server` VARCHAR(64) NULL,
    `was_executed` TINYINT NULL,
    `succeeded` TINYINT NULL,
    `report` VARCHAR(1024) NULL
);

ALTER TABLE alf_applied_patch
    ADD CONSTRAINT `PK__alf_appl__3213E83FA8BC8E29` PRIMARY KEY (id);


-- ==========================================
-- Table: alf_attributes
-- Created: 2014-11-25 03:45:38.210000
-- Modified: 2014-11-25 03:45:38.223000
-- ==========================================

CREATE TABLE alf_attributes (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `type` VARCHAR(1) NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `acl_id` DECIMAL(19,0) NULL,
    `bool_value` TINYINT NULL,
    `byte_value` TINYINT NULL,
    `short_value` INT NULL,
    `int_value` INT NULL,
    `long_value` DECIMAL(19,0) NULL,
    `DOUBLE_value` DOUBLE NULL,
    `double_value` DOUBLE NULL,
    `string_value` VARCHAR(1024) NULL,
    `serializable_value` LONGBLOB NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_attributes
    ADD CONSTRAINT `PK__alf_attr__3213E83F855C2DDB` PRIMARY KEY (id);

CREATE INDEX `fk_alf_attr_acl` ON alf_attributes (acl_id);


-- ==========================================
-- Table: alf_audit_app
-- Created: 2014-11-25 03:45:38.363000
-- Modified: 2014-11-25 03:45:38.373000
-- ==========================================

CREATE TABLE alf_audit_app (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` INT NOT NULL,
    `app_name_id` DECIMAL(19,0) NOT NULL,
    `audit_model_id` DECIMAL(19,0) NOT NULL,
    `disabled_paths_id` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_audit_app
    ADD CONSTRAINT `PK__alf_audi__3213E83F623F030A` PRIMARY KEY (id);

CREATE INDEX `fk_alf_aud_app_dis` ON alf_audit_app (disabled_paths_id);
CREATE INDEX `fk_alf_aud_app_mod` ON alf_audit_app (audit_model_id);
CREATE UNIQUE INDEX `idx_alf_aud_app_an` ON alf_audit_app (app_name_id);


-- ==========================================
-- Table: alf_audit_entry
-- Created: 2014-11-25 03:45:38.370000
-- Modified: 2014-11-25 03:45:38.383000
-- ==========================================

CREATE TABLE alf_audit_entry (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `audit_app_id` DECIMAL(19,0) NOT NULL,
    `audit_time` DECIMAL(19,0) NOT NULL,
    `audit_user_id` DECIMAL(19,0) NULL,
    `audit_values_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_audit_entry
    ADD CONSTRAINT `PK__alf_audi__3213E83FD3710B6C` PRIMARY KEY (id);

CREATE INDEX `fk_alf_aud_ent_app` ON alf_audit_entry (audit_app_id);
CREATE INDEX `fk_alf_aud_ent_pro` ON alf_audit_entry (audit_values_id);
CREATE INDEX `fk_alf_aud_ent_use` ON alf_audit_entry (audit_user_id);
CREATE INDEX `idx_alf_aud_ent_tm` ON alf_audit_entry (audit_time);


-- ==========================================
-- Table: alf_audit_model
-- Created: 2014-11-25 03:45:38.360000
-- Modified: 2014-11-25 03:45:38.370000
-- ==========================================

CREATE TABLE alf_audit_model (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `content_data_id` DECIMAL(19,0) NOT NULL,
    `content_crc` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_audit_model
    ADD CONSTRAINT `PK__alf_audi__3213E83FD96C2CDA` PRIMARY KEY (id);

CREATE INDEX `fk_alf_aud_mod_cd` ON alf_audit_model (content_data_id);
CREATE UNIQUE INDEX `idx_alf_aud_mod_cr` ON alf_audit_model (content_crc);


-- ==========================================
-- Table: alf_authority
-- Created: 2014-11-25 03:45:38.060000
-- Modified: 2014-11-25 03:45:38.087000
-- ==========================================

CREATE TABLE alf_authority (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `authority` VARCHAR(100) NULL,
    `crc` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_authority
    ADD CONSTRAINT `PK__alf_auth__3213E83FE9CE2594` PRIMARY KEY (id);

CREATE UNIQUE INDEX `authority` ON alf_authority (authority, crc);
CREATE INDEX `idx_alf_auth_aut` ON alf_authority (authority);


-- ==========================================
-- Table: alf_authority_alias
-- Created: 2014-11-25 03:45:38.087000
-- Modified: 2014-11-25 03:45:38.097000
-- ==========================================

CREATE TABLE alf_authority_alias (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `auth_id` DECIMAL(19,0) NOT NULL,
    `alias_id` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_authority_alias
    ADD CONSTRAINT `PK__alf_auth__3213E83FD608AA04` PRIMARY KEY (id);

CREATE UNIQUE INDEX `auth_id` ON alf_authority_alias (auth_id, alias_id);
CREATE INDEX `fk_alf_autha_ali` ON alf_authority_alias (alias_id);
CREATE INDEX `fk_alf_autha_aut` ON alf_authority_alias (auth_id);


-- ==========================================
-- Table: alf_child_assoc
-- Created: 2014-11-25 03:45:38.193000
-- Modified: 2014-11-25 03:45:38.217000
-- ==========================================

CREATE TABLE alf_child_assoc (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `parent_node_id` DECIMAL(19,0) NOT NULL,
    `type_qname_id` DECIMAL(19,0) NOT NULL,
    `child_node_name_crc` DECIMAL(19,0) NOT NULL,
    `child_node_name` VARCHAR(50) NOT NULL,
    `child_node_id` DECIMAL(19,0) NOT NULL,
    `qname_ns_id` DECIMAL(19,0) NOT NULL,
    `qname_localname` VARCHAR(255) NOT NULL,
    `qname_crc` DECIMAL(19,0) NOT NULL,
    `is_primary` TINYINT NULL,
    `assoc_index` INT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_child_assoc
    ADD CONSTRAINT `PK__alf_chil__3213E83FB05F6BCB` PRIMARY KEY (id);

CREATE INDEX `fk_alf_cass_cnode` ON alf_child_assoc (child_node_id);
CREATE INDEX `fk_alf_cass_pnode` ON alf_child_assoc (parent_node_id);
CREATE INDEX `fk_alf_cass_qnns` ON alf_child_assoc (qname_ns_id);
CREATE INDEX `fk_alf_cass_tqn` ON alf_child_assoc (type_qname_id);
CREATE INDEX `idx_alf_cass_pri` ON alf_child_assoc (parent_node_id, is_primary, child_node_id);
CREATE INDEX `idx_alf_cass_qncrc` ON alf_child_assoc (qname_crc, type_qname_id, parent_node_id);
CREATE UNIQUE INDEX `parent_node_id` ON alf_child_assoc (parent_node_id, type_qname_id, child_node_name_crc, child_node_name);


-- ==========================================
-- Table: alf_content_data
-- Created: 2014-11-25 03:45:38.293000
-- Modified: 2014-11-25 03:46:46.600000
-- ==========================================

CREATE TABLE alf_content_data (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `content_url_id` DECIMAL(19,0) NULL,
    `content_mimetype_id` DECIMAL(19,0) NULL,
    `content_encoding_id` DECIMAL(19,0) NULL,
    `content_locale_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_content_data
    ADD CONSTRAINT `PK__alf_cont__3213E83F1CE9F61D` PRIMARY KEY (id);

CREATE INDEX `CONTENT_URL_REF_IDX` ON alf_content_data (content_url_id);
CREATE INDEX `fk_alf_cont_enc` ON alf_content_data (content_encoding_id);
CREATE INDEX `fk_alf_cont_loc` ON alf_content_data (content_locale_id);
CREATE INDEX `fk_alf_cont_mim` ON alf_content_data (content_mimetype_id);
CREATE INDEX `fk_alf_cont_url` ON alf_content_data (content_url_id);


-- ==========================================
-- Table: alf_content_url
-- Created: 2014-11-25 03:45:38.290000
-- Modified: 2014-11-25 03:46:46.587000
-- ==========================================

CREATE TABLE alf_content_url (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `content_url` VARCHAR(255) NOT NULL,
    `content_url_short` VARCHAR(12) NOT NULL,
    `content_url_crc` DECIMAL(19,0) NOT NULL,
    `content_size` DECIMAL(19,0) NOT NULL,
    `orphan_time` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_content_url
    ADD CONSTRAINT `PK__alf_cont__3213E83FA9486923` PRIMARY KEY (id);

CREATE UNIQUE INDEX `idx_alf_conturl_cr` ON alf_content_url (content_url_short, content_url_crc);
CREATE INDEX `idx_alf_conturl_ot` ON alf_content_url (orphan_time);


-- ==========================================
-- Table: alf_encoding
-- Created: 2014-11-25 03:45:38.277000
-- Modified: 2014-11-25 03:45:38.297000
-- ==========================================

CREATE TABLE alf_encoding (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `encoding_str` VARCHAR(100) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_encoding
    ADD CONSTRAINT `PK__alf_enco__3213E83F23A8246D` PRIMARY KEY (id);

CREATE UNIQUE INDEX `UQ__alf_enco__9335B4D344E1CCC7` ON alf_encoding (encoding_str);


-- ==========================================
-- Table: alf_global_attributes
-- Created: 2014-11-25 03:45:38.213000
-- Modified: 2014-11-25 03:45:38.220000
-- ==========================================

CREATE TABLE alf_global_attributes (
    `name` VARCHAR(160) NOT NULL,
    `attribute` DECIMAL(19,0) NULL
);

ALTER TABLE alf_global_attributes
    ADD CONSTRAINT `PK__alf_glob__72E12F1AD6CE43E7` PRIMARY KEY (name);

CREATE UNIQUE INDEX `attribute` ON alf_global_attributes (attribute);
CREATE INDEX `fk_alf_gatt_att` ON alf_global_attributes (attribute);


-- ==========================================
-- Table: alf_list_attribute_entries
-- Created: 2014-11-25 03:45:38.217000
-- Modified: 2014-11-25 03:45:38.223000
-- ==========================================

CREATE TABLE alf_list_attribute_entries (
    `list_id` DECIMAL(19,0) NOT NULL,
    `mindex` INT NOT NULL,
    `attribute_id` DECIMAL(19,0) NULL
);

ALTER TABLE alf_list_attribute_entries
    ADD CONSTRAINT `PK__alf_list__0D0F4F069EFCE958` PRIMARY KEY (list_id, mindex);

CREATE INDEX `fk_alf_lent_att` ON alf_list_attribute_entries (attribute_id);
CREATE INDEX `fk_alf_lent_latt` ON alf_list_attribute_entries (list_id);


-- ==========================================
-- Table: alf_locale
-- Created: 2014-11-25 03:45:38.207000
-- Modified: 2014-11-25 03:45:38.297000
-- ==========================================

CREATE TABLE alf_locale (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `locale_str` VARCHAR(20) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_locale
    ADD CONSTRAINT `PK__alf_loca__3213E83F3D21314B` PRIMARY KEY (id);

CREATE UNIQUE INDEX `locale_str` ON alf_locale (locale_str);


-- ==========================================
-- Table: alf_lock
-- Created: 2014-11-25 03:45:38.260000
-- Modified: 2014-11-25 03:45:38.267000
-- ==========================================

CREATE TABLE alf_lock (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `shared_resource_id` DECIMAL(19,0) NOT NULL,
    `excl_resource_id` DECIMAL(19,0) NOT NULL,
    `lock_token` VARCHAR(36) NOT NULL,
    `start_time` DECIMAL(19,0) NOT NULL,
    `expiry_time` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_lock
    ADD CONSTRAINT `PK__alf_lock__3213E83FBEC06345` PRIMARY KEY (id);

CREATE INDEX `fk_alf_lock_excl` ON alf_lock (excl_resource_id);
CREATE UNIQUE INDEX `idx_alf_lock_key` ON alf_lock (shared_resource_id, excl_resource_id);


-- ==========================================
-- Table: alf_lock_resource
-- Created: 2014-11-25 03:45:38.257000
-- Modified: 2014-11-25 03:45:38.263000
-- ==========================================

CREATE TABLE alf_lock_resource (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `qname_ns_id` DECIMAL(19,0) NOT NULL,
    `qname_localname` VARCHAR(255) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_lock_resource
    ADD CONSTRAINT `PK__alf_lock__3213E83F26D42CDF` PRIMARY KEY (id);

CREATE UNIQUE INDEX `idx_alf_lockr_key` ON alf_lock_resource (qname_ns_id, qname_localname);


-- ==========================================
-- Table: alf_map_attribute_entries
-- Created: 2014-11-25 03:45:38.223000
-- Modified: 2014-11-25 03:45:38.230000
-- ==========================================

CREATE TABLE alf_map_attribute_entries (
    `map_id` DECIMAL(19,0) NOT NULL,
    `mkey` VARCHAR(160) NOT NULL,
    `attribute_id` DECIMAL(19,0) NULL
);

ALTER TABLE alf_map_attribute_entries
    ADD CONSTRAINT `PK__alf_map___E57C53D1AA8E062C` PRIMARY KEY (map_id, mkey);

CREATE INDEX `fk_alf_matt_att` ON alf_map_attribute_entries (attribute_id);
CREATE INDEX `fk_alf_matt_matt` ON alf_map_attribute_entries (map_id);


-- ==========================================
-- Table: alf_mimetype
-- Created: 2014-11-25 03:45:38.273000
-- Modified: 2014-11-25 03:45:38.297000
-- ==========================================

CREATE TABLE alf_mimetype (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `mimetype_str` VARCHAR(100) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_mimetype
    ADD CONSTRAINT `PK__alf_mime__3213E83F88777436` PRIMARY KEY (id);

CREATE UNIQUE INDEX `UQ__alf_mime__25B6CB677F2DBB6B` ON alf_mimetype (mimetype_str);


-- ==========================================
-- Table: alf_namespace
-- Created: 2014-11-25 03:45:38.043000
-- Modified: 2014-11-25 03:45:38.260000
-- ==========================================

CREATE TABLE alf_namespace (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `uri` VARCHAR(100) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_namespace
    ADD CONSTRAINT `PK__alf_name__3213E83FD86F49BC` PRIMARY KEY (id);

CREATE UNIQUE INDEX `uri` ON alf_namespace (uri);


-- ==========================================
-- Table: alf_node
-- Created: 2014-11-25 03:45:38.180000
-- Modified: 2014-11-25 03:45:38.490000
-- ==========================================

CREATE TABLE alf_node (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `store_id` DECIMAL(19,0) NOT NULL,
    `uuid` VARCHAR(36) NOT NULL,
    `transaction_id` DECIMAL(19,0) NOT NULL,
    `node_deleted` TINYINT NOT NULL,
    `type_qname_id` DECIMAL(19,0) NOT NULL,
    `acl_id` DECIMAL(19,0) NULL,
    `audit_creator` VARCHAR(255) NULL,
    `audit_created` VARCHAR(30) NULL,
    `audit_modifier` VARCHAR(255) NULL,
    `audit_modified` VARCHAR(30) NULL,
    `audit_accessed` VARCHAR(30) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_node
    ADD CONSTRAINT `PK__alf_node__3213E83F0F1E6181` PRIMARY KEY (id);

CREATE INDEX `fk_alf_node_acl` ON alf_node (acl_id);
CREATE INDEX `fk_alf_node_store` ON alf_node (store_id);
CREATE INDEX `fk_alf_node_tqn` ON alf_node (type_qname_id);
CREATE INDEX `fk_alf_node_txn` ON alf_node (transaction_id);
CREATE INDEX `idx_alf_node_del` ON alf_node (node_deleted);
CREATE UNIQUE INDEX `store_id` ON alf_node (store_id, uuid);


-- ==========================================
-- Table: alf_node_aspects
-- Created: 2014-11-25 03:45:38.230000
-- Modified: 2014-11-25 03:45:38.237000
-- ==========================================

CREATE TABLE alf_node_aspects (
    `node_id` DECIMAL(19,0) NOT NULL,
    `qname_id` DECIMAL(19,0) NOT NULL
);

ALTER TABLE alf_node_aspects
    ADD CONSTRAINT `PK__alf_node__76933324E7F540A5` PRIMARY KEY (node_id, qname_id);

CREATE INDEX `fk_alf_nasp_n` ON alf_node_aspects (node_id);
CREATE INDEX `fk_alf_nasp_qn` ON alf_node_aspects (qname_id);


-- ==========================================
-- Table: alf_node_assoc
-- Created: 2014-11-25 03:45:38.237000
-- Modified: 2014-11-25 03:45:38.250000
-- ==========================================

CREATE TABLE alf_node_assoc (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `source_node_id` DECIMAL(19,0) NOT NULL,
    `target_node_id` DECIMAL(19,0) NOT NULL,
    `type_qname_id` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_node_assoc
    ADD CONSTRAINT `PK__alf_node__3213E83FC10EFF63` PRIMARY KEY (id);

CREATE INDEX `fk_alf_nass_snode` ON alf_node_assoc (source_node_id);
CREATE INDEX `fk_alf_nass_tnode` ON alf_node_assoc (target_node_id);
CREATE INDEX `fk_alf_nass_tqn` ON alf_node_assoc (type_qname_id);
CREATE UNIQUE INDEX `source_node_id` ON alf_node_assoc (source_node_id, target_node_id, type_qname_id);


-- ==========================================
-- Table: alf_node_properties
-- Created: 2014-11-25 03:45:38.243000
-- Modified: 2014-11-25 03:46:46.613000
-- ==========================================

CREATE TABLE alf_node_properties (
    `node_id` DECIMAL(19,0) NOT NULL,
    `actual_type_n` INT NOT NULL,
    `persisted_type_n` INT NOT NULL,
    `boolean_value` TINYINT NULL,
    `long_value` DECIMAL(19,0) NULL,
    `DOUBLE_value` DOUBLE NULL,
    `double_value` DOUBLE NULL,
    `string_value` VARCHAR(1024) NULL,
    `serializable_value` LONGBLOB NULL,
    `qname_id` DECIMAL(19,0) NOT NULL,
    `list_index` INT NOT NULL,
    `locale_id` DECIMAL(19,0) NOT NULL
);

ALTER TABLE alf_node_properties
    ADD CONSTRAINT `PK__alf_node__262638E48C3AF818` PRIMARY KEY (node_id, qname_id, list_index, locale_id);

CREATE INDEX `ACT_PERS_TYPES_IDX` ON alf_node_properties (actual_type_n, persisted_type_n);
CREATE INDEX `fk_alf_nprop_loc` ON alf_node_properties (locale_id);
CREATE INDEX `fk_alf_nprop_n` ON alf_node_properties (node_id);
CREATE INDEX `fk_alf_nprop_qn` ON alf_node_properties (qname_id);


-- ==========================================
-- Table: alf_permission
-- Created: 2014-11-25 03:45:38.053000
-- Modified: 2014-11-25 03:45:38.067000
-- ==========================================

CREATE TABLE alf_permission (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `type_qname_id` DECIMAL(19,0) NOT NULL,
    `name` VARCHAR(100) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_permission
    ADD CONSTRAINT `PK__alf_perm__3213E83FE32FDFF1` PRIMARY KEY (id);

CREATE INDEX `fk_alf_perm_tqn` ON alf_permission (type_qname_id);
CREATE UNIQUE INDEX `type_qname_id` ON alf_permission (type_qname_id, name);


-- ==========================================
-- Table: alf_prop_class
-- Created: 2014-11-25 03:45:38.310000
-- Modified: 2014-11-25 03:45:38.317000
-- ==========================================

CREATE TABLE alf_prop_class (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `java_class_name` VARCHAR(255) NOT NULL,
    `java_class_name_short` VARCHAR(32) NOT NULL,
    `java_class_name_crc` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_prop_class
    ADD CONSTRAINT `PK__alf_prop__3213E83F69C859BB` PRIMARY KEY (id);

CREATE INDEX `idx_alf_propc_clas` ON alf_prop_class (java_class_name);
CREATE UNIQUE INDEX `idx_alf_propc_crc` ON alf_prop_class (java_class_name_crc, java_class_name_short);


-- ==========================================
-- Table: alf_prop_date_value
-- Created: 2014-11-25 03:45:38.313000
-- Modified: 2014-11-25 03:45:38.317000
-- ==========================================

CREATE TABLE alf_prop_date_value (
    `DATE_value` DECIMAL(19,0) NOT NULL,
    `full_year` INT NOT NULL,
    `half_of_year` TINYINT NOT NULL,
    `quarter_of_year` TINYINT NOT NULL,
    `month_of_year` TINYINT NOT NULL,
    `week_of_year` TINYINT NOT NULL,
    `week_of_month` TINYINT NOT NULL,
    `day_of_year` INT NOT NULL,
    `day_of_month` TINYINT NOT NULL,
    `day_of_week` TINYINT NOT NULL
);

ALTER TABLE alf_prop_date_value
    ADD CONSTRAINT `PK__alf_prop__92DCEC6950DD433E` PRIMARY KEY (DATE_value);

CREATE INDEX `idx_alf_propdt_dt` ON alf_prop_date_value (full_year, month_of_year, day_of_month);


-- ==========================================
-- Table: alf_prop_double_value
-- Created: 2014-11-25 03:45:38.317000
-- Modified: 2014-11-25 03:45:38.320000
-- ==========================================

CREATE TABLE alf_prop_double_value (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `double_value` DOUBLE NOT NULL,
    PRIMARY KEY (`id`)

)

ALTER TABLE alf_prop_double_value
    ADD CONSTRAINT `PK__alf_prop__3213E83F407FA1E7` PRIMARY KEY (id);

CREATE UNIQUE INDEX `idx_alf_propd_val` ON alf_prop_double_value (double_value);


-- ==========================================
-- Table: alf_prop_link
-- Created: 2014-11-25 03:45:38.330000
-- Modified: 2014-11-25 03:45:38.350000
-- ==========================================

CREATE TABLE alf_prop_link (
    `root_prop_id` DECIMAL(19,0) NOT NULL,
    `prop_index` DECIMAL(19,0) NOT NULL,
    `contained_in` DECIMAL(19,0) NOT NULL,
    `key_prop_id` DECIMAL(19,0) NOT NULL,
    `value_prop_id` DECIMAL(19,0) NOT NULL
);

ALTER TABLE alf_prop_link
    ADD CONSTRAINT `PK__alf_prop__4391290953168D32` PRIMARY KEY (root_prop_id, contained_in, prop_index);

CREATE INDEX `fk_alf_propln_key` ON alf_prop_link (key_prop_id);
CREATE INDEX `fk_alf_propln_val` ON alf_prop_link (value_prop_id);
CREATE INDEX `idx_alf_propln_for` ON alf_prop_link (root_prop_id, key_prop_id, value_prop_id);


-- ==========================================
-- Table: alf_prop_root
-- Created: 2014-11-25 03:45:38.330000
-- Modified: 2014-11-25 03:45:38.370000
-- ==========================================

CREATE TABLE alf_prop_root (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` INT NOT NULL,
    PRIMARY KEY (`id`)

)

ALTER TABLE alf_prop_root
    ADD CONSTRAINT `PK__alf_prop__3213E83F6B444F9C` PRIMARY KEY (id);


-- ==========================================
-- Table: alf_prop_serializable_value
-- Created: 2014-11-25 03:45:38.323000
-- Modified: 2014-11-25 03:45:38.323000
-- ==========================================

CREATE TABLE alf_prop_serializable_value (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `serializable_value` LONGBLOB NOT NULL,
    PRIMARY KEY (`id`)

)

ALTER TABLE alf_prop_serializable_value
    ADD CONSTRAINT `PK__alf_prop__3213E83F757CEBE9` PRIMARY KEY (id);


-- ==========================================
-- Table: alf_prop_string_value
-- Created: 2014-11-25 03:45:38.320000
-- Modified: 2014-11-25 03:45:38.323000
-- ==========================================

CREATE TABLE alf_prop_string_value (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `string_value` VARCHAR(1024) NOT NULL,
    `string_end_lower` VARCHAR(16) NOT NULL,
    `string_crc` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_prop_string_value
    ADD CONSTRAINT `PK__alf_prop__3213E83F06006586` PRIMARY KEY (id);

CREATE UNIQUE INDEX `idx_alf_props_crc` ON alf_prop_string_value (string_end_lower, string_crc);


-- ==========================================
-- Table: alf_prop_unique_ctx
-- Created: 2014-11-25 03:45:38.340000
-- Modified: 2014-11-25 03:45:38.367000
-- ==========================================

CREATE TABLE alf_prop_unique_ctx (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` INT NOT NULL,
    `value1_prop_id` DECIMAL(19,0) NOT NULL,
    `value2_prop_id` DECIMAL(19,0) NOT NULL,
    `value3_prop_id` DECIMAL(19,0) NOT NULL,
    `prop1_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_prop_unique_ctx
    ADD CONSTRAINT `PK__alf_prop__3213E83F9A00E3B3` PRIMARY KEY (id);

CREATE INDEX `fk_alf_propuctx_p1` ON alf_prop_unique_ctx (prop1_id);
CREATE INDEX `fk_alf_propuctx_v2` ON alf_prop_unique_ctx (value2_prop_id);
CREATE INDEX `fk_alf_propuctx_v3` ON alf_prop_unique_ctx (value3_prop_id);
CREATE UNIQUE INDEX `idx_alf_propuctx` ON alf_prop_unique_ctx (value1_prop_id, value2_prop_id, value3_prop_id);


-- ==========================================
-- Table: alf_prop_value
-- Created: 2014-11-25 03:45:38.327000
-- Modified: 2014-11-25 03:45:38.370000
-- ==========================================

CREATE TABLE alf_prop_value (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `actual_type_id` DECIMAL(19,0) NOT NULL,
    `persisted_type` TINYINT NOT NULL,
    `long_value` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_prop_value
    ADD CONSTRAINT `PK__alf_prop__3213E83F7087DBC9` PRIMARY KEY (id);

CREATE UNIQUE INDEX `idx_alf_propv_act` ON alf_prop_value (actual_type_id, long_value);
CREATE INDEX `idx_alf_propv_per` ON alf_prop_value (persisted_type, long_value);


-- ==========================================
-- Table: alf_qname
-- Created: 2014-11-25 03:45:38.047000
-- Modified: 2014-11-25 03:45:38.453000
-- ==========================================

CREATE TABLE alf_qname (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `ns_id` DECIMAL(19,0) NOT NULL,
    `local_name` VARCHAR(200) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_qname
    ADD CONSTRAINT `PK__alf_qnam__3213E83FC31D650E` PRIMARY KEY (id);

CREATE INDEX `fk_alf_qname_ns` ON alf_qname (ns_id);
CREATE UNIQUE INDEX `ns_id` ON alf_qname (ns_id, local_name);


-- ==========================================
-- Table: alf_server
-- Created: 2014-11-25 03:45:38.090000
-- Modified: 2014-11-25 03:45:38.097000
-- ==========================================

CREATE TABLE alf_server (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `ip_address` VARCHAR(39) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_server
    ADD CONSTRAINT `PK__alf_serv__3213E83FD64576BA` PRIMARY KEY (id);

CREATE UNIQUE INDEX `ip_address` ON alf_server (ip_address);


-- ==========================================
-- Table: alf_store
-- Created: 2014-11-25 03:45:38.173000
-- Modified: 2014-11-25 03:45:38.193000
-- ==========================================

CREATE TABLE alf_store (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `protocol` VARCHAR(50) NOT NULL,
    `identifier` VARCHAR(100) NOT NULL,
    `root_node_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_store
    ADD CONSTRAINT `PK__alf_stor__3213E83FD0E1276D` PRIMARY KEY (id);

CREATE INDEX `fk_alf_store_root` ON alf_store (root_node_id);
CREATE UNIQUE INDEX `protocol` ON alf_store (protocol, identifier);


-- ==========================================
-- Table: alf_transaction
-- Created: 2014-11-25 03:45:38.097000
-- Modified: 2014-11-25 03:46:46.617000
-- ==========================================

CREATE TABLE alf_transaction (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `server_id` DECIMAL(19,0) NULL,
    `change_txn_id` VARCHAR(56) NOT NULL,
    `commit_time_ms` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_transaction
    ADD CONSTRAINT `PK__alf_tran__3213E83F36DBC5E2` PRIMARY KEY (id);

CREATE INDEX `COMMIT_TIME_MS_ID_SID_IDX` ON alf_transaction (commit_time_ms, id, server_id);
CREATE INDEX `fk_alf_txn_svr` ON alf_transaction (server_id);
CREATE INDEX `idx_alf_txn_ctms` ON alf_transaction (commit_time_ms);


-- ==========================================
-- Table: alf_usage_delta
-- Created: 2014-11-25 03:45:38.487000
-- Modified: 2014-11-25 03:45:38.490000
-- ==========================================

CREATE TABLE alf_usage_delta (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version` DECIMAL(19,0) NOT NULL,
    `node_id` DECIMAL(19,0) NOT NULL,
    `delta_size` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE alf_usage_delta
    ADD CONSTRAINT `PK__alf_usag__3213E83F0F7D0AC7` PRIMARY KEY (id);

CREATE INDEX `fk_alf_usaged_n` ON alf_usage_delta (node_id);


-- ==========================================
-- Table: avm_aspects
-- Created: 2014-11-25 03:45:38.380000
-- Modified: 2014-11-25 03:45:38.450000
-- ==========================================

CREATE TABLE avm_aspects (
    `node_id` DECIMAL(19,0) NOT NULL,
    `qname_id` DECIMAL(19,0) NOT NULL
);

ALTER TABLE avm_aspects
    ADD CONSTRAINT `PK__avm_aspe__769333247137DC92` PRIMARY KEY (node_id, qname_id);

CREATE INDEX `fk_avm_nasp_n` ON avm_aspects (node_id);
CREATE INDEX `fk_avm_nasp_qn` ON avm_aspects (qname_id);


-- ==========================================
-- Table: avm_child_entries
-- Created: 2014-11-25 03:45:38.383000
-- Modified: 2014-11-25 03:45:38.453000
-- ==========================================

CREATE TABLE avm_child_entries (
    `parent_id` DECIMAL(19,0) NOT NULL,
    `lc_name` VARCHAR(160) NOT NULL,
    `name` VARCHAR(160) NOT NULL,
    `child_id` DECIMAL(19,0) NOT NULL
);

ALTER TABLE avm_child_entries
    ADD CONSTRAINT `PK__avm_chil__AB6CCF08E0E13C4D` PRIMARY KEY (parent_id, lc_name);

CREATE INDEX `fk_avm_ce_child` ON avm_child_entries (child_id);
CREATE INDEX `fk_avm_ce_parent` ON avm_child_entries (parent_id);
CREATE INDEX `idx_avm_ce_lc_name` ON avm_child_entries (lc_name, parent_id);


-- ==========================================
-- Table: avm_history_links
-- Created: 2014-11-25 03:45:38.383000
-- Modified: 2014-11-25 03:45:38.453000
-- ==========================================

CREATE TABLE avm_history_links (
    `ancestor` DECIMAL(19,0) NOT NULL,
    `descendent` DECIMAL(19,0) NOT NULL
);

ALTER TABLE avm_history_links
    ADD CONSTRAINT `PK__avm_hist__E3725EF9F8F8B10E` PRIMARY KEY (ancestor, descendent);

CREATE INDEX `fk_avm_hl_ancestor` ON avm_history_links (ancestor);
CREATE INDEX `fk_avm_hl_desc` ON avm_history_links (descendent);
CREATE INDEX `idx_avm_hl_revpk` ON avm_history_links (descendent, ancestor);


-- ==========================================
-- Table: avm_merge_links
-- Created: 2014-11-25 03:45:38.387000
-- Modified: 2014-11-25 03:45:38.427000
-- ==========================================

CREATE TABLE avm_merge_links (
    `mfrom` DECIMAL(19,0) NOT NULL,
    `mto` DECIMAL(19,0) NOT NULL
);

ALTER TABLE avm_merge_links
    ADD CONSTRAINT `PK__avm_merg__24FA01F2A17A4EA8` PRIMARY KEY (mfrom, mto);

CREATE INDEX `fk_avm_ml_from` ON avm_merge_links (mfrom);
CREATE INDEX `fk_avm_ml_to` ON avm_merge_links (mto);


-- ==========================================
-- Table: avm_node_properties
-- Created: 2014-11-25 03:45:38.390000
-- Modified: 2014-11-25 03:45:38.450000
-- ==========================================

CREATE TABLE avm_node_properties (
    `node_id` DECIMAL(19,0) NOT NULL,
    `actual_type_n` INT NOT NULL,
    `persisted_type_n` INT NOT NULL,
    `multi_valued` TINYINT NOT NULL,
    `boolean_value` TINYINT NULL,
    `long_value` DECIMAL(19,0) NULL,
    `DOUBLE_value` DOUBLE NULL,
    `double_value` DOUBLE NULL,
    `string_value` VARCHAR(1024) NULL,
    `serializable_value` LONGBLOB NULL,
    `qname_id` DECIMAL(19,0) NOT NULL
);

ALTER TABLE avm_node_properties
    ADD CONSTRAINT `PK__avm_node__769333241A7F57CA` PRIMARY KEY (node_id, qname_id);

CREATE INDEX `fk_avm_nprop_n` ON avm_node_properties (node_id);
CREATE INDEX `fk_avm_nprop_qn` ON avm_node_properties (qname_id);


-- ==========================================
-- Table: avm_nodes
-- Created: 2014-11-25 03:45:38.390000
-- Modified: 2014-11-25 03:45:38.450000
-- ==========================================

CREATE TABLE avm_nodes (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `class_type` VARCHAR(20) NOT NULL,
    `vers` DECIMAL(19,0) NOT NULL,
    `version_id` INT NOT NULL,
    `guid` VARCHAR(36) NULL,
    `creator` VARCHAR(255) NOT NULL,
    `owner` VARCHAR(255) NOT NULL,
    `lastModifier` VARCHAR(255) NOT NULL,
    `createDate` DECIMAL(19,0) NOT NULL,
    `modDate` DECIMAL(19,0) NOT NULL,
    `accessDate` DECIMAL(19,0) NOT NULL,
    `is_root` TINYINT NULL,
    `store_new_id` DECIMAL(19,0) NULL,
    `acl_id` DECIMAL(19,0) NULL,
    `deletedType` INT NULL,
    `layer_id` DECIMAL(19,0) NULL,
    `indirection` VARCHAR(1024) NULL,
    `indirection_version` INT NULL,
    `primary_indirection` TINYINT NULL,
    `opacity` TINYINT NULL,
    `content_url` VARCHAR(128) NULL,
    `mime_type` VARCHAR(100) NULL,
    `encoding` VARCHAR(16) NULL,
    `length` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE avm_nodes
    ADD CONSTRAINT `PK__avm_node__3213E83F499BA436` PRIMARY KEY (id);

CREATE INDEX `fk_avm_n_acl` ON avm_nodes (acl_id);
CREATE INDEX `fk_avm_n_store` ON avm_nodes (store_new_id);
CREATE INDEX `idx_avm_n_pi` ON avm_nodes (primary_indirection);


-- ==========================================
-- Table: avm_store_properties
-- Created: 2014-11-25 03:45:38.393000
-- Modified: 2014-11-25 03:45:38.453000
-- ==========================================

CREATE TABLE avm_store_properties (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `avm_store_id` DECIMAL(19,0) NULL,
    `qname_id` DECIMAL(19,0) NOT NULL,
    `actual_type_n` INT NOT NULL,
    `persisted_type_n` INT NOT NULL,
    `multi_valued` TINYINT NOT NULL,
    `boolean_value` TINYINT NULL,
    `long_value` DECIMAL(19,0) NULL,
    `DOUBLE_value` DOUBLE NULL,
    `double_value` DOUBLE NULL,
    `string_value` VARCHAR(1024) NULL,
    `serializable_value` LONGBLOB NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE avm_store_properties
    ADD CONSTRAINT `PK__avm_stor__3213E83F7745AD8B` PRIMARY KEY (id);

CREATE INDEX `fk_avm_sprop_qname` ON avm_store_properties (qname_id);
CREATE INDEX `fk_avm_sprop_store` ON avm_store_properties (avm_store_id);


-- ==========================================
-- Table: avm_stores
-- Created: 2014-11-25 03:45:38.393000
-- Modified: 2014-11-25 03:45:38.447000
-- ==========================================

CREATE TABLE avm_stores (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `vers` DECIMAL(19,0) NOT NULL,
    `name` VARCHAR(255) NULL,
    `next_version_id` INT NOT NULL,
    `current_root_id` DECIMAL(19,0) NULL,
    `acl_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE avm_stores
    ADD CONSTRAINT `PK__avm_stor__3213E83FB7C43518` PRIMARY KEY (id);

CREATE INDEX `fk_avm_s_acl` ON avm_stores (acl_id);
CREATE INDEX `fk_avm_s_root` ON avm_stores (current_root_id);
CREATE UNIQUE INDEX `UQ__avm_stor__72E12F1B7EF5E282` ON avm_stores (name);


-- ==========================================
-- Table: avm_version_layered_node_entry
-- Created: 2014-11-25 03:45:38.400000
-- Modified: 2014-11-25 03:45:38.440000
-- ==========================================

CREATE TABLE avm_version_layered_node_entry (
    `version_root_id` DECIMAL(19,0) NOT NULL,
    `md5sum` VARCHAR(32) NOT NULL,
    `path` VARCHAR(1024) NULL
);

ALTER TABLE avm_version_layered_node_entry
    ADD CONSTRAINT `PK__avm_vers__F3ED4C9457342DC5` PRIMARY KEY (version_root_id, md5sum);

CREATE INDEX `fk_avm_vlne_vr` ON avm_version_layered_node_entry (version_root_id);


-- ==========================================
-- Table: avm_version_roots
-- Created: 2014-11-25 03:45:38.400000
-- Modified: 2014-11-25 03:45:38.457000
-- ==========================================

CREATE TABLE avm_version_roots (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `version_id` INT NOT NULL,
    `avm_store_id` DECIMAL(19,0) NOT NULL,
    `create_date` DECIMAL(19,0) NOT NULL,
    `creator` VARCHAR(255) NOT NULL,
    `root_id` DECIMAL(19,0) NOT NULL,
    `tag` VARCHAR(255) NULL,
    `description` VARCHAR(1024) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE avm_version_roots
    ADD CONSTRAINT `PK__avm_vers__3213E83F3AA1DEC2` PRIMARY KEY (id);

CREATE INDEX `fk_avm_vr_root` ON avm_version_roots (root_id);
CREATE INDEX `fk_avm_vr_store` ON avm_version_roots (avm_store_id);
CREATE INDEX `idx_avm_vr_revuq` ON avm_version_roots (avm_store_id, version_id);
CREATE INDEX `idx_avm_vr_version` ON avm_version_roots (version_id);
CREATE UNIQUE INDEX `UQ__avm_vers__EF2A660E853BEB3E` ON avm_version_roots (version_id, avm_store_id);


-- ==========================================
-- Table: JBPM_ACTION
-- Created: 2014-11-25 03:45:06.477000
-- Modified: 2014-11-25 03:45:39.933000
-- ==========================================

CREATE TABLE JBPM_ACTION (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `class` char(1) NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `ISPROPAGATIONALLOWED_` TINYINT NULL,
    `ACTIONEXPRESSION_` VARCHAR(255) NULL,
    `ISASYNC_` TINYINT NULL,
    `REFERENCEDACTION_` DECIMAL(19,0) NULL,
    `ACTIONDELEGATION_` DECIMAL(19,0) NULL,
    `EVENT_` DECIMAL(19,0) NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `TIMERNAME_` VARCHAR(255) NULL,
    `DUEDATE_` VARCHAR(255) NULL,
    `REPEAT_` VARCHAR(255) NULL,
    `TRANSITIONNAME_` VARCHAR(255) NULL,
    `TIMERACTION_` DECIMAL(19,0) NULL,
    `EXPRESSION_` TEXT NULL,
    `EVENTINDEX_` INT NULL,
    `EXCEPTIONHANDLER_` DECIMAL(19,0) NULL,
    `EXCEPTIONHANDLERINDEX_` INT NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_ACTION
    ADD CONSTRAINT `PK__JBPM_ACT__C4971C0FD53A8A2C` PRIMARY KEY (ID_);

CREATE INDEX `FK_ACTION_ACTNDEL` ON JBPM_ACTION (ACTIONDELEGATION_);
CREATE INDEX `FK_ACTION_EVENT` ON JBPM_ACTION (EVENT_);
CREATE INDEX `FK_ACTION_EXPTHDL` ON JBPM_ACTION (EXCEPTIONHANDLER_);
CREATE INDEX `FK_ACTION_PROCDEF` ON JBPM_ACTION (PROCESSDEFINITION_);
CREATE INDEX `FK_ACTION_REFACT` ON JBPM_ACTION (REFERENCEDACTION_);
CREATE INDEX `FK_CRTETIMERACT_TA` ON JBPM_ACTION (TIMERACTION_);


-- ==========================================
-- Table: JBPM_BYTEARRAY
-- Created: 2014-11-25 03:45:06.480000
-- Modified: 2014-11-25 03:45:27.670000
-- ==========================================

CREATE TABLE JBPM_BYTEARRAY (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `FILEDEFINITION_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_BYTEARRAY
    ADD CONSTRAINT `PK__JBPM_BYT__C4971C0FD3B340EE` PRIMARY KEY (ID_);

CREATE INDEX `FK_BYTEARR_FILDEF` ON JBPM_BYTEARRAY (FILEDEFINITION_);


-- ==========================================
-- Table: JBPM_BYTEBLOCK
-- Created: 2014-11-25 03:45:06.480000
-- Modified: 2014-11-25 03:45:27.673000
-- ==========================================

CREATE TABLE JBPM_BYTEBLOCK (
    `PROCESSFILE_` DECIMAL(19,0) NOT NULL,
    `BYTES_` varbinary NULL,
    `INDEX_` INT NOT NULL
);

ALTER TABLE JBPM_BYTEBLOCK
    ADD CONSTRAINT `PK__JBPM_BYT__84996C4EBEF9524E` PRIMARY KEY (PROCESSFILE_, INDEX_);

CREATE INDEX `FK_BYTEBLOCK_FILE` ON JBPM_BYTEBLOCK (PROCESSFILE_);


-- ==========================================
-- Table: JBPM_COMMENT
-- Created: 2014-11-25 03:45:06.483000
-- Modified: 2014-11-25 03:45:39.937000
-- ==========================================

CREATE TABLE JBPM_COMMENT (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `ACTORID_` VARCHAR(255) NULL,
    `TIME_` DATETIME NULL,
    `MESSAGE_` TEXT NULL,
    `TOKEN_` DECIMAL(19,0) NULL,
    `TASKINSTANCE_` DECIMAL(19,0) NULL,
    `TOKENINDEX_` INT NULL,
    `TASKINSTANCEINDEX_` INT NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_COMMENT
    ADD CONSTRAINT `PK__JBPM_COM__C4971C0F98B5F30D` PRIMARY KEY (ID_);

CREATE INDEX `FK_COMMENT_TOKEN` ON JBPM_COMMENT (TOKEN_);
CREATE INDEX `FK_COMMENT_TSK` ON JBPM_COMMENT (TASKINSTANCE_);


-- ==========================================
-- Table: JBPM_DECISIONCONDITIONS
-- Created: 2014-11-25 03:45:06.487000
-- Modified: 2014-11-25 03:45:39.937000
-- ==========================================

CREATE TABLE JBPM_DECISIONCONDITIONS (
    `DECISION_` DECIMAL(19,0) NOT NULL,
    `TRANSITIONNAME_` VARCHAR(255) NULL,
    `EXPRESSION_` VARCHAR(255) NULL,
    `INDEX_` INT NOT NULL
);

ALTER TABLE JBPM_DECISIONCONDITIONS
    ADD CONSTRAINT `PK__JBPM_DEC__AAF025B0570710F3` PRIMARY KEY (DECISION_, INDEX_);

CREATE INDEX `FK_DECCOND_DEC` ON JBPM_DECISIONCONDITIONS (DECISION_);


-- ==========================================
-- Table: JBPM_DELEGATION
-- Created: 2014-11-25 03:45:06.490000
-- Modified: 2014-11-25 03:45:27.673000
-- ==========================================

CREATE TABLE JBPM_DELEGATION (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASSNAME_` TEXT NULL,
    `CONFIGURATION_` TEXT NULL,
    `CONFIGTYPE_` VARCHAR(255) NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_DELEGATION
    ADD CONSTRAINT `PK__JBPM_DEL__C4971C0FF9B9AA3A` PRIMARY KEY (ID_);

CREATE INDEX `FK_DELEGATION_PRCD` ON JBPM_DELEGATION (PROCESSDEFINITION_);


-- ==========================================
-- Table: JBPM_EVENT
-- Created: 2014-11-25 03:45:06.493000
-- Modified: 2014-11-25 03:45:39.947000
-- ==========================================

CREATE TABLE JBPM_EVENT (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `EVENTTYPE_` VARCHAR(255) NULL,
    `TYPE_` char(1) NULL,
    `GRAPHELEMENT_` DECIMAL(19,0) NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `NODE_` DECIMAL(19,0) NULL,
    `TRANSITION_` DECIMAL(19,0) NULL,
    `TASK_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_EVENT
    ADD CONSTRAINT `PK__JBPM_EVE__C4971C0F2BD7957B` PRIMARY KEY (ID_);

CREATE INDEX `FK_EVENT_NODE` ON JBPM_EVENT (NODE_);
CREATE INDEX `FK_EVENT_PROCDEF` ON JBPM_EVENT (PROCESSDEFINITION_);
CREATE INDEX `FK_EVENT_TASK` ON JBPM_EVENT (TASK_);
CREATE INDEX `FK_EVENT_TRANS` ON JBPM_EVENT (TRANSITION_);


-- ==========================================
-- Table: JBPM_EXCEPTIONHANDLER
-- Created: 2014-11-25 03:45:06.497000
-- Modified: 2014-11-25 03:45:06.823000
-- ==========================================

CREATE TABLE JBPM_EXCEPTIONHANDLER (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `EXCEPTIONCLASSNAME_` TEXT NULL,
    `TYPE_` char(1) NULL,
    `GRAPHELEMENT_` DECIMAL(19,0) NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `GRAPHELEMENTINDEX_` INT NULL,
    `NODE_` DECIMAL(19,0) NULL,
    `TRANSITION_` DECIMAL(19,0) NULL,
    `TASK_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_EXCEPTIONHANDLER
    ADD CONSTRAINT `PK__JBPM_EXC__C4971C0F662D0C68` PRIMARY KEY (ID_);


-- ==========================================
-- Table: JBPM_JOB
-- Created: 2014-11-25 03:45:06.497000
-- Modified: 2014-11-25 03:45:39.957000
-- ==========================================

CREATE TABLE JBPM_JOB (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `VERSION_` INT NOT NULL,
    `DUEDATE_` DATETIME NULL,
    `PROCESSINSTANCE_` DECIMAL(19,0) NULL,
    `TOKEN_` DECIMAL(19,0) NULL,
    `TASKINSTANCE_` DECIMAL(19,0) NULL,
    `ISSUSPENDED_` TINYINT NULL,
    `ISEXCLUSIVE_` TINYINT NULL,
    `LOCKOWNER_` VARCHAR(255) NULL,
    `LOCKTIME_` DATETIME NULL,
    `EXCEPTION_` TEXT NULL,
    `RETRIES_` INT NULL,
    `NAME_` VARCHAR(255) NULL,
    `REPEAT_` VARCHAR(255) NULL,
    `TRANSITIONNAME_` VARCHAR(255) NULL,
    `ACTION_` DECIMAL(19,0) NULL,
    `GRAPHELEMENTTYPE_` VARCHAR(255) NULL,
    `GRAPHELEMENT_` DECIMAL(19,0) NULL,
    `NODE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_JOB
    ADD CONSTRAINT `PK__JBPM_JOB__C4971C0FA2062DE0` PRIMARY KEY (ID_);

CREATE INDEX `FK_JOB_ACTION` ON JBPM_JOB (ACTION_);
CREATE INDEX `FK_JOB_NODE` ON JBPM_JOB (NODE_);
CREATE INDEX `FK_JOB_PRINST` ON JBPM_JOB (PROCESSINSTANCE_);
CREATE INDEX `FK_JOB_TOKEN` ON JBPM_JOB (TOKEN_);
CREATE INDEX `FK_JOB_TSKINST` ON JBPM_JOB (TASKINSTANCE_);


-- ==========================================
-- Table: JBPM_LOG
-- Created: 2014-11-25 03:45:06.500000
-- Modified: 2014-11-25 03:45:27.737000
-- ==========================================

CREATE TABLE JBPM_LOG (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `INDEX_` INT NULL,
    `DATE_` DATETIME NULL,
    `TOKEN_` DECIMAL(19,0) NULL,
    `PARENT_` DECIMAL(19,0) NULL,
    `MESSAGE_` TEXT NULL,
    `EXCEPTION_` TEXT NULL,
    `ACTION_` DECIMAL(19,0) NULL,
    `NODE_` DECIMAL(19,0) NULL,
    `ENTER_` DATETIME NULL,
    `LEAVE_` DATETIME NULL,
    `DURATION_` DECIMAL(19,0) NULL,
    `NEWLONGVALUE_` DECIMAL(19,0) NULL,
    `TRANSITION_` DECIMAL(19,0) NULL,
    `CHILD_` DECIMAL(19,0) NULL,
    `SOURCENODE_` DECIMAL(19,0) NULL,
    `DESTINATIONNODE_` DECIMAL(19,0) NULL,
    `VARIABLEINSTANCE_` DECIMAL(19,0) NULL,
    `OLDBYTEARRAY_` DECIMAL(19,0) NULL,
    `NEWBYTEARRAY_` DECIMAL(19,0) NULL,
    `OLDDATEVALUE_` DATETIME NULL,
    `NEWDATEVALUE_` DATETIME NULL,
    `OLDDOUBLEVALUE_` DOUBLE NULL,
    `NEWDOUBLEVALUE_` DOUBLE NULL,
    `OLDLONGIDCLASS_` VARCHAR(255) NULL,
    `OLDLONGIDVALUE_` DECIMAL(19,0) NULL,
    `NEWLONGIDCLASS_` VARCHAR(255) NULL,
    `NEWLONGIDVALUE_` DECIMAL(19,0) NULL,
    `OLDSTRINGIDCLASS_` VARCHAR(255) NULL,
    `OLDSTRINGIDVALUE_` VARCHAR(255) NULL,
    `NEWSTRINGIDCLASS_` VARCHAR(255) NULL,
    `NEWSTRINGIDVALUE_` VARCHAR(255) NULL,
    `OLDLONGVALUE_` DECIMAL(19,0) NULL,
    `OLDSTRINGVALUE_` TEXT NULL,
    `NEWSTRINGVALUE_` TEXT NULL,
    `TASKINSTANCE_` DECIMAL(19,0) NULL,
    `TASKACTORID_` VARCHAR(255) NULL,
    `TASKOLDACTORID_` VARCHAR(255) NULL,
    `SWIMLANEINSTANCE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_LOG
    ADD CONSTRAINT `PK__JBPM_LOG__C4971C0FAA8BB7C2` PRIMARY KEY (ID_);

CREATE INDEX `FK_LOG_ACTION` ON JBPM_LOG (ACTION_);
CREATE INDEX `FK_LOG_CHILDTOKEN` ON JBPM_LOG (CHILD_);
CREATE INDEX `FK_LOG_DESTNODE` ON JBPM_LOG (DESTINATIONNODE_);
CREATE INDEX `FK_LOG_NEWBYTES` ON JBPM_LOG (NEWBYTEARRAY_);
CREATE INDEX `FK_LOG_NODE` ON JBPM_LOG (NODE_);
CREATE INDEX `FK_LOG_OLDBYTES` ON JBPM_LOG (OLDBYTEARRAY_);
CREATE INDEX `FK_LOG_PARENT` ON JBPM_LOG (PARENT_);
CREATE INDEX `FK_LOG_SOURCENODE` ON JBPM_LOG (SOURCENODE_);
CREATE INDEX `FK_LOG_SWIMINST` ON JBPM_LOG (SWIMLANEINSTANCE_);
CREATE INDEX `FK_LOG_TASKINST` ON JBPM_LOG (TASKINSTANCE_);
CREATE INDEX `FK_LOG_TOKEN` ON JBPM_LOG (TOKEN_);
CREATE INDEX `FK_LOG_TRANSITION` ON JBPM_LOG (TRANSITION_);
CREATE INDEX `FK_LOG_VARINST` ON JBPM_LOG (VARIABLEINSTANCE_);


-- ==========================================
-- Table: JBPM_MODULEDEFINITION
-- Created: 2014-11-25 03:45:06.503000
-- Modified: 2014-11-25 03:45:39.957000
-- ==========================================

CREATE TABLE JBPM_MODULEDEFINITION (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `STARTTASK_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_MODULEDEFINITION
    ADD CONSTRAINT `PK__JBPM_MOD__C4971C0FAC64DDA0` PRIMARY KEY (ID_);

CREATE INDEX `FK_MODDEF_PROCDEF` ON JBPM_MODULEDEFINITION (PROCESSDEFINITION_);
CREATE INDEX `FK_TSKDEF_START` ON JBPM_MODULEDEFINITION (STARTTASK_);


-- ==========================================
-- Table: JBPM_MODULEINSTANCE
-- Created: 2014-11-25 03:45:06.507000
-- Modified: 2014-11-25 03:45:27.680000
-- ==========================================

CREATE TABLE JBPM_MODULEINSTANCE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `VERSION_` INT NOT NULL,
    `PROCESSINSTANCE_` DECIMAL(19,0) NULL,
    `TASKMGMTDEFINITION_` DECIMAL(19,0) NULL,
    `NAME_` VARCHAR(255) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_MODULEINSTANCE
    ADD CONSTRAINT `PK__JBPM_MOD__C4971C0F8AC63619` PRIMARY KEY (ID_);

CREATE INDEX `FK_MODINST_PRCINST` ON JBPM_MODULEINSTANCE (PROCESSINSTANCE_);
CREATE INDEX `FK_TASKMGTINST_TMD` ON JBPM_MODULEINSTANCE (TASKMGMTDEFINITION_);


-- ==========================================
-- Table: JBPM_NODE
-- Created: 2014-11-25 03:45:06.547000
-- Modified: 2014-11-25 03:45:39.970000
-- ==========================================

CREATE TABLE JBPM_NODE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `DESCRIPTION_` TEXT NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `ISASYNC_` TINYINT NULL,
    `ISASYNCEXCL_` TINYINT NULL,
    `ACTION_` DECIMAL(19,0) NULL,
    `SUPERSTATE_` DECIMAL(19,0) NULL,
    `SUBPROCNAME_` VARCHAR(255) NULL,
    `SUBPROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `DECISIONEXPRESSION_` VARCHAR(255) NULL,
    `DECISIONDELEGATION` DECIMAL(19,0) NULL,
    `SCRIPT_` DECIMAL(19,0) NULL,
    `PARENTLOCKMODE_` VARCHAR(255) NULL,
    `SIGNAL_` INT NULL,
    `CREATETASKS_` TINYINT NULL,
    `ENDTASKS_` TINYINT NULL,
    `NODECOLLECTIONINDEX_` INT NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_NODE
    ADD CONSTRAINT `PK__JBPM_NOD__C4971C0FC87B38AE` PRIMARY KEY (ID_);

CREATE INDEX `FK_DECISION_DELEG` ON JBPM_NODE (DECISIONDELEGATION);
CREATE INDEX `FK_NODE_ACTION` ON JBPM_NODE (ACTION_);
CREATE INDEX `FK_NODE_PROCDEF` ON JBPM_NODE (PROCESSDEFINITION_);
CREATE INDEX `FK_NODE_SCRIPT` ON JBPM_NODE (SCRIPT_);
CREATE INDEX `FK_NODE_SUPERSTATE` ON JBPM_NODE (SUPERSTATE_);
CREATE INDEX `FK_PROCST_SBPRCDEF` ON JBPM_NODE (SUBPROCESSDEFINITION_);


-- ==========================================
-- Table: JBPM_POOLEDACTOR
-- Created: 2014-11-25 03:45:06.550000
-- Modified: 2014-11-25 03:45:39.960000
-- ==========================================

CREATE TABLE JBPM_POOLEDACTOR (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `ACTORID_` VARCHAR(255) NULL,
    `SWIMLANEINSTANCE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_POOLEDACTOR
    ADD CONSTRAINT `PK__JBPM_POO__C4971C0F9B5ED54D` PRIMARY KEY (ID_);

CREATE INDEX `FK_POOLEDACTOR_SLI` ON JBPM_POOLEDACTOR (SWIMLANEINSTANCE_);


-- ==========================================
-- Table: JBPM_PROCESSDEFINITION
-- Created: 2014-11-25 03:45:06.550000
-- Modified: 2014-11-25 03:45:39.963000
-- ==========================================

CREATE TABLE JBPM_PROCESSDEFINITION (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `DESCRIPTION_` TEXT NULL,
    `VERSION_` INT NULL,
    `ISTERMINATIONIMPLICIT_` TINYINT NULL,
    `STARTSTATE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_PROCESSDEFINITION
    ADD CONSTRAINT `PK__JBPM_PRO__C4971C0F0D2B1EA7` PRIMARY KEY (ID_);

CREATE INDEX `FK_PROCDEF_STRTSTA` ON JBPM_PROCESSDEFINITION (STARTSTATE_);


-- ==========================================
-- Table: JBPM_PROCESSINSTANCE
-- Created: 2014-11-25 03:45:06.553000
-- Modified: 2014-11-25 03:45:27.683000
-- ==========================================

CREATE TABLE JBPM_PROCESSINSTANCE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `KEY_` VARCHAR(255) NULL,
    `START_` DATETIME NULL,
    `END_` DATETIME NULL,
    `ISSUSPENDED_` TINYINT NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `ROOTTOKEN_` DECIMAL(19,0) NULL,
    `SUPERPROCESSTOKEN_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_PROCESSINSTANCE
    ADD CONSTRAINT `PK__JBPM_PRO__C4971C0FA0AFF7CD` PRIMARY KEY (ID_);

CREATE INDEX `FK_PROCIN_PROCDEF` ON JBPM_PROCESSINSTANCE (PROCESSDEFINITION_);
CREATE INDEX `FK_PROCIN_ROOTTKN` ON JBPM_PROCESSINSTANCE (ROOTTOKEN_);
CREATE INDEX `FK_PROCIN_SPROCTKN` ON JBPM_PROCESSINSTANCE (SUPERPROCESSTOKEN_);


-- ==========================================
-- Table: JBPM_RUNTIMEACTION
-- Created: 2014-11-25 03:45:06.557000
-- Modified: 2014-11-25 03:45:39.967000
-- ==========================================

CREATE TABLE JBPM_RUNTIMEACTION (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `EVENTTYPE_` VARCHAR(255) NULL,
    `TYPE_` char(1) NULL,
    `GRAPHELEMENT_` DECIMAL(19,0) NULL,
    `PROCESSINSTANCE_` DECIMAL(19,0) NULL,
    `ACTION_` DECIMAL(19,0) NULL,
    `PROCESSINSTANCEINDEX_` INT NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_RUNTIMEACTION
    ADD CONSTRAINT `PK__JBPM_RUN__C4971C0FA44DB536` PRIMARY KEY (ID_);

CREATE INDEX `FK_RTACTN_ACTION` ON JBPM_RUNTIMEACTION (ACTION_);
CREATE INDEX `FK_RTACTN_PROCINST` ON JBPM_RUNTIMEACTION (PROCESSINSTANCE_);


-- ==========================================
-- Table: JBPM_SWIMLANE
-- Created: 2014-11-25 03:45:06.557000
-- Modified: 2014-11-25 03:45:39.970000
-- ==========================================

CREATE TABLE JBPM_SWIMLANE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `ACTORIDEXPRESSION_` VARCHAR(255) NULL,
    `POOLEDACTORSEXPRESSION_` VARCHAR(255) NULL,
    `ASSIGNMENTDELEGATION_` DECIMAL(19,0) NULL,
    `TASKMGMTDEFINITION_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_SWIMLANE
    ADD CONSTRAINT `PK__JBPM_SWI__C4971C0F9C091E53` PRIMARY KEY (ID_);

CREATE INDEX `FK_SWL_ASSDEL` ON JBPM_SWIMLANE (ASSIGNMENTDELEGATION_);
CREATE INDEX `FK_SWL_TSKMGMTDEF` ON JBPM_SWIMLANE (TASKMGMTDEFINITION_);


-- ==========================================
-- Table: JBPM_SWIMLANEINSTANCE
-- Created: 2014-11-25 03:45:06.560000
-- Modified: 2014-11-25 03:45:39.973000
-- ==========================================

CREATE TABLE JBPM_SWIMLANEINSTANCE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `ACTORID_` VARCHAR(255) NULL,
    `SWIMLANE_` DECIMAL(19,0) NULL,
    `TASKMGMTINSTANCE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_SWIMLANEINSTANCE
    ADD CONSTRAINT `PK__JBPM_SWI__C4971C0F6EF0B972` PRIMARY KEY (ID_);

CREATE INDEX `FK_SWIMLANEINST_SL` ON JBPM_SWIMLANEINSTANCE (SWIMLANE_);
CREATE INDEX `FK_SWIMLANEINST_TM` ON JBPM_SWIMLANEINSTANCE (TASKMGMTINSTANCE_);


-- ==========================================
-- Table: JBPM_TASK
-- Created: 2014-11-25 03:45:06.560000
-- Modified: 2014-11-25 03:45:40.027000
-- ==========================================

CREATE TABLE JBPM_TASK (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `DESCRIPTION_` TEXT NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `ISBLOCKING_` TINYINT NULL,
    `ISSIGNALLING_` TINYINT NULL,
    `CONDITION_` VARCHAR(255) NULL,
    `DUEDATE_` VARCHAR(255) NULL,
    `PRIORITY_` INT NULL,
    `ACTORIDEXPRESSION_` VARCHAR(255) NULL,
    `POOLEDACTORSEXPRESSION_` VARCHAR(255) NULL,
    `TASKMGMTDEFINITION_` DECIMAL(19,0) NULL,
    `TASKNODE_` DECIMAL(19,0) NULL,
    `STARTSTATE_` DECIMAL(19,0) NULL,
    `ASSIGNMENTDELEGATION_` DECIMAL(19,0) NULL,
    `SWIMLANE_` DECIMAL(19,0) NULL,
    `TASKCONTROLLER_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_TASK
    ADD CONSTRAINT `PK__JBPM_TAS__C4971C0FDBE2EE54` PRIMARY KEY (ID_);

CREATE INDEX `FK_TASK_ASSDEL` ON JBPM_TASK (ASSIGNMENTDELEGATION_);
CREATE INDEX `FK_TASK_PROCDEF` ON JBPM_TASK (PROCESSDEFINITION_);
CREATE INDEX `FK_TASK_STARTST` ON JBPM_TASK (STARTSTATE_);
CREATE INDEX `FK_TASK_SWIMLANE` ON JBPM_TASK (SWIMLANE_);
CREATE INDEX `FK_TASK_TASKMGTDEF` ON JBPM_TASK (TASKMGMTDEFINITION_);
CREATE INDEX `FK_TASK_TASKNODE` ON JBPM_TASK (TASKNODE_);
CREATE INDEX `FK_TSK_TSKCTRL` ON JBPM_TASK (TASKCONTROLLER_);


-- ==========================================
-- Table: JBPM_TASKACTORPOOL
-- Created: 2014-11-25 03:45:06.563000
-- Modified: 2014-11-25 03:45:40.030000
-- ==========================================

CREATE TABLE JBPM_TASKACTORPOOL (
    `TASKINSTANCE_` DECIMAL(19,0) NOT NULL,
    `POOLEDACTOR_` DECIMAL(19,0) NOT NULL
);

ALTER TABLE JBPM_TASKACTORPOOL
    ADD CONSTRAINT `PK__JBPM_TAS__AE563B953F482496` PRIMARY KEY (TASKINSTANCE_, POOLEDACTOR_);

CREATE INDEX `FK_TASKACTPL_TSKI` ON JBPM_TASKACTORPOOL (TASKINSTANCE_);
CREATE INDEX `FK_TSKACTPOL_PLACT` ON JBPM_TASKACTORPOOL (POOLEDACTOR_);


-- ==========================================
-- Table: JBPM_TASKCONTROLLER
-- Created: 2014-11-25 03:45:06.563000
-- Modified: 2014-11-25 03:45:27.673000
-- ==========================================

CREATE TABLE JBPM_TASKCONTROLLER (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `TASKCONTROLLERDELEGATION_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_TASKCONTROLLER
    ADD CONSTRAINT `PK__JBPM_TAS__C4971C0F2AED0114` PRIMARY KEY (ID_);

CREATE INDEX `FK_TSKCTRL_DELEG` ON JBPM_TASKCONTROLLER (TASKCONTROLLERDELEGATION_);


-- ==========================================
-- Table: JBPM_TASKINSTANCE
-- Created: 2014-11-25 03:45:06.567000
-- Modified: 2014-11-25 03:45:27.693000
-- ==========================================

CREATE TABLE JBPM_TASKINSTANCE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `VERSION_` INT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `DESCRIPTION_` TEXT NULL,
    `ACTORID_` VARCHAR(255) NULL,
    `CREATE_` DATETIME NULL,
    `START_` DATETIME NULL,
    `END_` DATETIME NULL,
    `DUEDATE_` DATETIME NULL,
    `PRIORITY_` INT NULL,
    `ISCANCELLED_` TINYINT NULL,
    `ISSUSPENDED_` TINYINT NULL,
    `ISOPEN_` TINYINT NULL,
    `ISSIGNALLING_` TINYINT NULL,
    `ISBLOCKING_` TINYINT NULL,
    `TASK_` DECIMAL(19,0) NULL,
    `TOKEN_` DECIMAL(19,0) NULL,
    `PROCINST_` DECIMAL(19,0) NULL,
    `SWIMLANINSTANCE_` DECIMAL(19,0) NULL,
    `TASKMGMTINSTANCE_` DECIMAL(19,0) NULL,
    `JBPM_ENGINE_NAME` VARCHAR(50) NULL
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_TASKINSTANCE
    ADD CONSTRAINT `PK__JBPM_TAS__C4971C0F707C5915` PRIMARY KEY (ID_);

CREATE INDEX `FK_TASKINST_SLINST` ON JBPM_TASKINSTANCE (SWIMLANINSTANCE_);
CREATE INDEX `FK_TASKINST_TASK` ON JBPM_TASKINSTANCE (TASK_);
CREATE INDEX `FK_TASKINST_TMINST` ON JBPM_TASKINSTANCE (TASKMGMTINSTANCE_);
CREATE INDEX `FK_TASKINST_TOKEN` ON JBPM_TASKINSTANCE (TOKEN_);
CREATE INDEX `FK_TSKINS_PRCINS` ON JBPM_TASKINSTANCE (PROCINST_);


-- ==========================================
-- Table: JBPM_TOKEN
-- Created: 2014-11-25 03:45:06.570000
-- Modified: 2014-11-25 03:45:27.700000
-- ==========================================

CREATE TABLE JBPM_TOKEN (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `START_` DATETIME NULL,
    `END_` DATETIME NULL,
    `NODEENTER_` DATETIME NULL,
    `NEXTLOGINDEX_` INT NULL,
    `ISABLETOREACTIVATEPARENT_` TINYINT NULL,
    `ISTERMINATIONIMPLICIT_` TINYINT NULL,
    `ISSUSPENDED_` TINYINT NULL,
    `LOCK_` VARCHAR(255) NULL,
    `NODE_` DECIMAL(19,0) NULL,
    `PROCESSINSTANCE_` DECIMAL(19,0) NULL,
    `PARENT_` DECIMAL(19,0) NULL,
    `SUBPROCESSINSTANCE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_TOKEN
    ADD CONSTRAINT `PK__JBPM_TOK__C4971C0F6733F10F` PRIMARY KEY (ID_);

CREATE INDEX `FK_TOKEN_NODE` ON JBPM_TOKEN (NODE_);
CREATE INDEX `FK_TOKEN_PARENT` ON JBPM_TOKEN (PARENT_);
CREATE INDEX `FK_TOKEN_PROCINST` ON JBPM_TOKEN (PROCESSINSTANCE_);
CREATE INDEX `FK_TOKEN_SUBPI` ON JBPM_TOKEN (SUBPROCESSINSTANCE_);


-- ==========================================
-- Table: JBPM_TOKENVARIABLEMAP
-- Created: 2014-11-25 03:45:06.570000
-- Modified: 2014-11-25 03:45:27.697000
-- ==========================================

CREATE TABLE JBPM_TOKENVARIABLEMAP (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VERSION_` INT NOT NULL,
    `TOKEN_` DECIMAL(19,0) NULL,
    `CONTEXTINSTANCE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_TOKENVARIABLEMAP
    ADD CONSTRAINT `PK__JBPM_TOK__C4971C0F0958EAC3` PRIMARY KEY (ID_);

CREATE INDEX `FK_TKVARMAP_CTXT` ON JBPM_TOKENVARIABLEMAP (CONTEXTINSTANCE_);
CREATE INDEX `FK_TKVARMAP_TOKEN` ON JBPM_TOKENVARIABLEMAP (TOKEN_);


-- ==========================================
-- Table: JBPM_TRANSITION
-- Created: 2014-11-25 03:45:06.573000
-- Modified: 2014-11-25 03:45:40.037000
-- ==========================================

CREATE TABLE JBPM_TRANSITION (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `DESCRIPTION_` TEXT NULL,
    `PROCESSDEFINITION_` DECIMAL(19,0) NULL,
    `FROM_` DECIMAL(19,0) NULL,
    `TO_` DECIMAL(19,0) NULL,
    `CONDITION_` VARCHAR(255) NULL,
    `FROMINDEX_` INT NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_TRANSITION
    ADD CONSTRAINT `PK__JBPM_TRA__C4971C0F74987A6F` PRIMARY KEY (ID_);

CREATE INDEX `FK_TRANS_PROCDEF` ON JBPM_TRANSITION (PROCESSDEFINITION_);
CREATE INDEX `FK_TRANSITION_FROM` ON JBPM_TRANSITION (FROM_);
CREATE INDEX `FK_TRANSITION_TO` ON JBPM_TRANSITION (TO_);


-- ==========================================
-- Table: JBPM_VARIABLEACCESS
-- Created: 2014-11-25 03:45:06.577000
-- Modified: 2014-11-25 03:45:40.040000
-- ==========================================

CREATE TABLE JBPM_VARIABLEACCESS (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `VARIABLENAME_` VARCHAR(255) NULL,
    `ACCESS_` VARCHAR(255) NULL,
    `MAPPEDNAME_` VARCHAR(255) NULL,
    `PROCESSSTATE_` DECIMAL(19,0) NULL,
    `TASKCONTROLLER_` DECIMAL(19,0) NULL,
    `INDEX_` INT NULL,
    `SCRIPT_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_VARIABLEACCESS
    ADD CONSTRAINT `PK__JBPM_VAR__C4971C0FA603DB80` PRIMARY KEY (ID_);

CREATE INDEX `FK_VARACC_PROCST` ON JBPM_VARIABLEACCESS (PROCESSSTATE_);
CREATE INDEX `FK_VARACC_SCRIPT` ON JBPM_VARIABLEACCESS (SCRIPT_);
CREATE INDEX `FK_VARACC_TSKCTRL` ON JBPM_VARIABLEACCESS (TASKCONTROLLER_);


-- ==========================================
-- Table: JBPM_VARIABLEINSTANCE
-- Created: 2014-11-25 03:45:06.580000
-- Modified: 2014-11-25 03:45:27.697000
-- ==========================================

CREATE TABLE JBPM_VARIABLEINSTANCE (
    `ID_` BIGINT AUTO_INCREMENT NOT NULL,
    `CLASS_` char(1) NOT NULL,
    `VERSION_` INT NOT NULL,
    `NAME_` VARCHAR(255) NULL,
    `CONVERTER_` char(1) NULL,
    `TOKEN_` DECIMAL(19,0) NULL,
    `TOKENVARIABLEMAP_` DECIMAL(19,0) NULL,
    `PROCESSINSTANCE_` DECIMAL(19,0) NULL,
    `BYTEARRAYVALUE_` DECIMAL(19,0) NULL,
    `DATEVALUE_` DATETIME NULL,
    `DOUBLEVALUE_` DOUBLE NULL,
    `LONGIDCLASS_` VARCHAR(255) NULL,
    `LONGVALUE_` DECIMAL(19,0) NULL,
    `STRINGIDCLASS_` VARCHAR(255) NULL,
    `STRINGVALUE_` VARCHAR(255) NULL,
    `TASKINSTANCE_` DECIMAL(19,0) NULL,
    PRIMARY KEY (`ID_`)
);

ALTER TABLE JBPM_VARIABLEINSTANCE
    ADD CONSTRAINT `PK__JBPM_VAR__C4971C0FA7B2777C` PRIMARY KEY (ID_);

CREATE INDEX `FK_BYTEINST_ARRAY` ON JBPM_VARIABLEINSTANCE (BYTEARRAYVALUE_);
CREATE INDEX `FK_VAR_TSKINST` ON JBPM_VARIABLEINSTANCE (TASKINSTANCE_);
CREATE INDEX `FK_VARINST_PRCINST` ON JBPM_VARIABLEINSTANCE (PROCESSINSTANCE_);
CREATE INDEX `FK_VARINST_TK` ON JBPM_VARIABLEINSTANCE (TOKEN_);
CREATE INDEX `FK_VARINST_TKVARMP` ON JBPM_VARIABLEINSTANCE (TOKENVARIABLEMAP_);


-- ==========================================
-- Table: JMS_MESSAGES
-- Created: 2014-11-25 03:44:48.693000
-- Modified: 2014-11-25 03:44:48.717000
-- ==========================================

CREATE TABLE JMS_MESSAGES (
    `MESSAGEID` INT NOT NULL,
    `DESTINATION` varchar(1024) NOT NULL,
    `TXID` INT NULL,
    `TXOP` char(1) NULL,
    `MESSAGEBLOB` LONGBLOB NULL
);

CREATE INDEX `JMS_MESSAGES_DESTINATION` ON JMS_MESSAGES (DESTINATION);
CREATE UNIQUE INDEX `JMS_MESSAGES_IDX` ON JMS_MESSAGES (MESSAGEID, DESTINATION);
CREATE INDEX `JMS_MESSAGES_TXOP_TXID` ON JMS_MESSAGES (TXOP, TXID);


-- ==========================================
-- Table: JMS_ROLES
-- Created: 2014-11-25 03:44:48.660000
-- Modified: 2014-11-25 03:44:48.660000
-- ==========================================

CREATE TABLE JMS_ROLES (
    `ROLEID` varchar(32) NOT NULL,
    `USERID` varchar(32) NOT NULL
);

ALTER TABLE JMS_ROLES
    ADD CONSTRAINT `PK__JMS_ROLE__FB9829BBD44D175D` PRIMARY KEY (USERID, ROLEID);


-- ==========================================
-- Table: JMS_SUBSCRIPTIONS
-- Created: 2014-11-25 03:44:48.670000
-- Modified: 2014-11-25 03:44:48.670000
-- ==========================================

CREATE TABLE JMS_SUBSCRIPTIONS (
    `CLIENTID` varchar(128) NOT NULL,
    `SUBNAME` varchar(128) NOT NULL,
    `TOPIC` varchar(255) NOT NULL,
    `SELECTOR` varchar(255) NULL
);

ALTER TABLE JMS_SUBSCRIPTIONS
    ADD CONSTRAINT `PK__JMS_SUBS__1FF24DBCBFA458AC` PRIMARY KEY (CLIENTID, SUBNAME);


-- ==========================================
-- Table: JMS_TRANSACTIONS
-- Created: 2014-11-25 03:44:48.710000
-- Modified: 2014-11-25 03:44:48.710000
-- ==========================================

CREATE TABLE JMS_TRANSACTIONS (
    `TXID` INT NOT NULL
);

ALTER TABLE JMS_TRANSACTIONS
    ADD CONSTRAINT `PK__JMS_TRAN__827BEF0EDBC47310` PRIMARY KEY (TXID);


-- ==========================================
-- Table: JMS_USERS
-- Created: 2014-11-25 03:44:48.637000
-- Modified: 2014-11-25 03:44:48.637000
-- ==========================================

CREATE TABLE JMS_USERS (
    `USERID` varchar(32) NOT NULL,
    `PASSWD` varchar(32) NOT NULL,
    `CLIENTID` varchar(128) NULL
);

ALTER TABLE JMS_USERS
    ADD CONSTRAINT `PK__JMS_USER__7B9E7F35CDACCA28` PRIMARY KEY (USERID);


-- ==========================================
-- Table: lr_address
-- Created: 2014-11-25 03:45:06.580000
-- Modified: 2014-11-25 03:45:27.153000
-- ==========================================

CREATE TABLE lr_address (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `address_area_name` VARCHAR(250) NULL,
    `street_number` VARCHAR(50) NULL,
    `street_name` VARCHAR(100) NULL,
    `building_name` VARCHAR(50) NULL,
    `building_number` INT NULL,
    `layout_name` DECIMAL(19,0) NULL,
    `postal_code` VARCHAR(10) NULL,
    `city` VARCHAR(100) NULL,
    `ward` VARCHAR(100) NULL,
    `cell` VARCHAR(100) NULL,
    `local_government_area` DECIMAL(19,0) NULL,
    `country` DECIMAL(19,0) NOT NULL,
    `region` DECIMAL(19,0) NOT NULL,
    `origin_region` DECIMAL(19,0) NULL,
    `district` DECIMAL(19,0) NOT NULL,
    `cadregion` DECIMAL(19,0) NOT NULL,
    `subdistrict` DECIMAL(19,0) NOT NULL,
    `subcounty` VARCHAR(30) NULL,
    `address_line1` VARCHAR(50) NULL,
    `address_line2` VARCHAR(100) NULL,
    `address_line3` VARCHAR(100) NULL,
    `district_text` VARCHAR(100) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL
);

ALTER TABLE lr_address
    ADD CONSTRAINT `PK__lr_addre__3213E83F6872A593` PRIMARY KEY (id);

CREATE INDEX `lr_address_city_idx` ON lr_address (city);
CREATE INDEX `lr_address_district_idx` ON lr_address (district);
CREATE INDEX `lr_address_region_idx` ON lr_address (region);
CREATE INDEX `lr_address_street_name_idx` ON lr_address (street_name);


-- ==========================================
-- Table: lr_admin_document_party
-- Created: 2014-11-25 03:45:06.583000
-- Modified: 2014-11-25 03:45:06.987000
-- ==========================================

CREATE TABLE lr_admin_document_party (
    `document` DECIMAL(19,0) NOT NULL,
    `party` DECIMAL(19,0) NOT NULL,
    `party_index` INT NOT NULL
);

ALTER TABLE lr_admin_document_party
    ADD CONSTRAINT `PK__lr_admin__FC70D9A9500F9FF4` PRIMARY KEY (document, party_index);


-- ==========================================
-- Table: lr_admin_document_rrr
-- Created: 2014-11-25 03:45:06.593000
-- Modified: 2014-11-25 03:45:06.990000
-- ==========================================

CREATE TABLE lr_admin_document_rrr (
    `document` DECIMAL(19,0) NOT NULL,
    `rrr` DECIMAL(19,0) NOT NULL,
    `rrr_index` INT NOT NULL
);

ALTER TABLE lr_admin_document_rrr
    ADD CONSTRAINT `PK__lr_admin__1BEF61927B6B04FA` PRIMARY KEY (document, rrr_index);


-- ==========================================
-- Table: lr_admin_source_document
-- Created: 2014-11-25 03:45:06.593000
-- Modified: 2014-11-25 03:45:06.990000
-- ==========================================

CREATE TABLE lr_admin_source_document (
    `id` DECIMAL(19,0) NOT NULL,
    `purchase_price` DOUBLE NULL,
    `memo_text` VARCHAR(2500) NULL
);

ALTER TABLE lr_admin_source_document
    ADD CONSTRAINT `PK__lr_admin__3213E83F96542700` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_applicant
-- Created: 2014-11-25 03:45:06.597000
-- Modified: 2014-11-25 03:45:06.997000
-- ==========================================

CREATE TABLE lr_applicant (
    `id` DECIMAL(19,0) NOT NULL,
    `application_type` DECIMAL(19,0) NOT NULL,
    `delivery_type` DECIMAL(19,0) NOT NULL
);

ALTER TABLE lr_applicant
    ADD CONSTRAINT `PK__lr_appli__3213E83FA30AC0EE` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_batch
-- Created: 2014-11-25 03:45:06.597000
-- Modified: 2014-11-25 03:45:27.143000
-- ==========================================

CREATE TABLE lr_batch (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `batch_number` VARCHAR(50) NULL,
    `application_status` DECIMAL(19,0) NOT NULL,
    `invoice_number` VARCHAR(150) NULL,
    `create_date` DATETIME NULL,
    `delivery_date` DATETIME NULL,
    `office` DECIMAL(19,0) NULL,
    `comments` VARCHAR(800) NULL,
    `decision` VARCHAR(100) NULL,
    `decision_date` DATETIME NULL,
    `decision_number` VARCHAR(50) NULL,
    `attachments` VARCHAR(255) NULL,
    `registrar` VARCHAR(50) NULL,
    `registration_date` DATETIME NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL
);

ALTER TABLE lr_batch
    ADD CONSTRAINT `PK__lr_batch__3213E83F7DF19F79` PRIMARY KEY (id);

CREATE INDEX `lr_batch_batch_status_idx` ON lr_batch (application_status);
CREATE INDEX `lr_batch_office_idx` ON lr_batch (office);


-- ==========================================
-- Table: lr_batch_party
-- Created: 2014-11-25 03:45:06.600000
-- Modified: 2014-11-25 03:45:27.140000
-- ==========================================

CREATE TABLE lr_batch_party (
    `batch` DECIMAL(19,0) NOT NULL,
    `party` DECIMAL(19,0) NOT NULL,
    `party_index` INT NOT NULL
);

ALTER TABLE lr_batch_party
    ADD CONSTRAINT `PK__lr_batch__7B90C77A3264FB65` PRIMARY KEY (batch, party_index);

CREATE INDEX `lr_batch_party__idx` ON lr_batch_party (batch, party);


-- ==========================================
-- Table: lr_batch_related
-- Created: 2014-11-25 03:45:06.600000
-- Modified: 2014-11-25 03:45:06.600000
-- ==========================================

CREATE TABLE lr_batch_related (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `parent_id` DECIMAL(19,0) NOT NULL,
    `child_id` DECIMAL(19,0) NOT NULL,
    `process_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_batch_related
    ADD CONSTRAINT `PK__lr_batch__3213E83F8FBA7294` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_billing
-- Created: 2014-11-25 03:45:06.603000
-- Modified: 2014-11-25 03:45:07.190000
-- ==========================================

CREATE TABLE lr_billing (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `invoice_number` VARCHAR(50) NULL,
    `total_amount` DOUBLE NULL,
    `status` DECIMAL(19,0) NOT NULL,
    `invoice_type` DECIMAL(19,0) NOT NULL,
    `wires_trx_id` DECIMAL(19,0) NULL,
    `wrx_date_submitted` DATETIME NULL,
    `wrx_date_accepted` DATETIME NULL,
    `due_date` DATETIME NULL,
    `party` DECIMAL(19,0) NULL,
    `party_contact` DECIMAL(19,0) NULL,
    `ref_number` VARCHAR(50) NULL,
    `description` VARCHAR(800) NULL,
    `comments` VARCHAR(800) NULL,
    `submitted_by` VARCHAR(50) NULL,
    `bil1` VARCHAR(50) NULL,
    `bil2` VARCHAR(50) NULL,
    `bil_dict1` DECIMAL(19,0) NOT NULL,
    `bil_dict2` DECIMAL(19,0) NOT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL
);

ALTER TABLE lr_billing
    ADD CONSTRAINT `PK__lr_billi__3213E83F7730DC45` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_billing_dist_line
-- Created: 2014-11-25 03:45:06.607000
-- Modified: 2014-11-25 03:45:07.013000
-- ==========================================

CREATE TABLE lr_billing_dist_line (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `trans_code` VARCHAR(50) NULL,
    `amount` DOUBLE NULL,
    `flex_field_1` VARCHAR(250) NULL,
    `flex_field_2` VARCHAR(250) NULL,
    `flex_field_3` VARCHAR(250) NULL,
    `flex_field_4` VARCHAR(250) NULL,
    `flex_field_5` VARCHAR(250) NULL,
    `wires_dist_line_id` VARCHAR(50) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `line_id` DECIMAL(19,0) NULL,
    `line_index` INT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_billing_dist_line
    ADD CONSTRAINT `PK__lr_billi__3213E83F44848EE7` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_billing_line
-- Created: 2014-11-25 03:45:06.610000
-- Modified: 2014-11-25 03:45:07.017000
-- ==========================================

CREATE TABLE lr_billing_line (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `line_type` VARCHAR(50) NULL,
    `quantity` DOUBLE NULL,
    `amount` DOUBLE NULL,
    `total_amount` DOUBLE NULL,
    `wires_line_id` VARCHAR(50) NULL,
    `description` VARCHAR(800) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `bill_id` DECIMAL(19,0) NULL,
    `bill_index` INT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_billing_line
    ADD CONSTRAINT `PK__lr_billi__3213E83FBC0C2018` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_building
-- Created: 2014-11-25 03:45:06.610000
-- Modified: 2014-11-25 03:45:07.033000
-- ==========================================

CREATE TABLE lr_building (
    `id` DECIMAL(19,0) NOT NULL,
    `compl_number` VARCHAR(30) NULL,
    `actual_use_type` DECIMAL(19,0) NOT NULL,
    `number_of_units` INT NULL,
    `number_of_floors` INT NULL,
    `floor_area` DOUBLE NULL,
    `floor_area_unit_type` DECIMAL(19,0) NOT NULL,
    `internal_area` DOUBLE NULL,
    `internal_area_unit_type` DECIMAL(19,0) NOT NULL,
    `unit_factor` INT NULL,
    `adjacents` VARCHAR(500) NULL,
    `build_category` DECIMAL(19,0) NOT NULL,
    `build_purpose` DECIMAL(19,0) NOT NULL,
    `build_date1` DATETIME NULL,
    `build_date2` DATETIME NULL
);

ALTER TABLE lr_building
    ADD CONSTRAINT `PK__lr_build__3213E83FC46ED5CC` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_building_unit
-- Created: 2014-11-25 03:45:06.613000
-- Modified: 2014-11-25 03:45:27.223000
-- ==========================================

CREATE TABLE lr_building_unit (
    `id` DECIMAL(19,0) NOT NULL,
    `unit_number` VARCHAR(30) NULL,
    `building_number` VARCHAR(30) NULL,
    `compl_number` VARCHAR(30) NULL,
    `condo_plan` VARCHAR(20) NULL,
    `use_type` DECIMAL(19,0) NOT NULL,
    `bunit_type` DECIMAL(19,0) NULL,
    `bunit_category` DECIMAL(19,0) NOT NULL,
    `bunit_purpose` DECIMAL(19,0) NOT NULL,
    `use_typespecificbld` VARCHAR(50) NULL,
    `unit_factor` INT NULL,
    `unit_type` DECIMAL(19,0) NOT NULL,
    `number_of_units` INT NULL,
    `number_of_floors` INT NULL,
    `floor_type` DECIMAL(19,0) NOT NULL,
    `floor_area` DOUBLE NULL,
    `floor_area_unit_type` DECIMAL(19,0) NOT NULL,
    `internal_area` DOUBLE NULL,
    `internal_area_unit_type` DECIMAL(19,0) NOT NULL,
    `adjacents` VARCHAR(500) NULL,
    `bunit1` VARCHAR(50) NULL,
    `bunit2` VARCHAR(50) NULL,
    `bunit_dict1` DECIMAL(19,0) NOT NULL,
    `bunit_dict2` DECIMAL(19,0) NOT NULL,
    `bunit_date1` DATETIME NULL,
    `bunit_date2` DATETIME NULL,
    `bunit_count1` INT NULL,
    `bunit_count2` INT NULL,
    `plot_uid` VARCHAR(50) NULL
);

ALTER TABLE lr_building_unit
    ADD CONSTRAINT `PK__lr_build__3213E83FDC7F7700` PRIMARY KEY (id);

CREATE INDEX `lr_building_unit_use_type_idx` ON lr_building_unit (use_type);


-- ==========================================
-- Table: lr_business_calendar
-- Created: 2014-11-25 03:45:06.613000
-- Modified: 2014-11-25 03:45:06.613000
-- ==========================================

CREATE TABLE lr_business_calendar (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `code` VARCHAR(255) NOT NULL,
    `label` VARCHAR(255) NOT NULL,
    `day_part` VARCHAR(500) NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_business_calendar
    ADD CONSTRAINT `PK__lr_busin__3214EC072C47328F` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_condition
-- Created: 2014-11-25 03:45:06.617000
-- Modified: 2014-11-25 03:45:07.190000
-- ==========================================

CREATE TABLE lr_condition (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `condition_type` DECIMAL(19,0) NOT NULL,
    `condition_seq` DECIMAL(19,0) NULL,
    `condition_number` VARCHAR(100) NULL,
    `cond_stage` VARCHAR(150) NULL,
    `condition_text` VARCHAR(1500) NULL,
    `original_text` VARCHAR(1000) NULL,
    `custom_condition` TINYINT NULL,
    `last_edited_by` VARCHAR(255) NULL,
    `sign_by` VARCHAR(100) NULL,
    `validated_by` VARCHAR(100) NULL,
    `last_edited` DATETIME NULL,
    `received_date` DATETIME NULL,
    `validated_date` DATETIME NULL,
    `monitored` TINYINT NULL,
    `cond_status` DECIMAL(19,0) NOT NULL,
    `cond1` VARCHAR(50) NULL,
    `cond2` VARCHAR(50) NULL,
    `cond_dict1` DECIMAL(19,0) NOT NULL,
    `cond_dict2` DECIMAL(19,0) NOT NULL,
    `cond_count1` INT NULL,
    `cond_count2` INT NULL,
    `transaction_` DECIMAL(19,0) NULL,
    `condition_index` INT NULL
);

ALTER TABLE lr_condition
    ADD CONSTRAINT `PK__lr_condi__3213E83F05064C95` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_contact
-- Created: 2014-11-25 03:45:06.620000
-- Modified: 2014-11-25 03:45:27.157000
-- ==========================================

CREATE TABLE lr_contact (
    `id` DECIMAL(19,0) NOT NULL,
    `contact_type` DECIMAL(19,0) NOT NULL
);

ALTER TABLE lr_contact
    ADD CONSTRAINT `PK__lr_conta__3213E83F98CC3DCD` PRIMARY KEY (id);

CREATE INDEX `lr_contact_contact_type_idx` ON lr_contact (contact_type);


-- ==========================================
-- Table: lr_corporation
-- Created: 2014-11-25 03:45:06.620000
-- Modified: 2014-11-25 03:45:27.160000
-- ==========================================

CREATE TABLE lr_corporation (
    `id` DECIMAL(19,0) NOT NULL,
    `name` VARCHAR(150) NULL,
    `represent_name` VARCHAR(50) NULL,
    `gsm_number` VARCHAR(50) NULL,
    `cac_number` VARCHAR(50) NULL,
    `corp1` VARCHAR(50) NULL,
    `corp2` VARCHAR(50) NULL,
    `corp_dict1` DECIMAL(19,0) NOT NULL,
    `corp_dict2` DECIMAL(19,0) NOT NULL
);

ALTER TABLE lr_corporation
    ADD CONSTRAINT `PK__lr_corpo__3213E83FDCC2D0FA` PRIMARY KEY (id);

CREATE INDEX `lr_corporation_name_idx` ON lr_corporation (name);


-- ==========================================
-- Table: lr_dictionary
-- Created: 2014-11-25 03:45:06.623000
-- Modified: 2015-05-24 15:15:14.233000
-- ==========================================

CREATE TABLE lr_dictionary (
    `Id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `code` VARCHAR(64) NOT NULL,
    `label` VARCHAR(254) NOT NULL,
    `descr` VARCHAR(1000) NULL,
    `category` VARCHAR(64) NOT NULL,
    `general_term` TINYINT NULL,
    `sort_order` INT NULL,
    `hidden` TINYINT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `label_lang` VARCHAR(254) NULL,
    `descr_lang` VARCHAR(1000) NULL,
    `parentcode` VARCHAR(64) NULL
);

ALTER TABLE lr_dictionary
    ADD CONSTRAINT `PK__lr_dicti__3214EC0729C33D08` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_document_ext
-- Created: 2014-11-25 03:45:06.627000
-- Modified: 2014-11-25 03:45:06.627000
-- ==========================================

CREATE TABLE lr_document_ext (
    `parent_id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `extended_comments` VARCHAR(2000) NULL,
    `extended_params` VARCHAR(1000) NULL
);

ALTER TABLE lr_document_ext
    ADD CONSTRAINT `PK__lr_docum__F2A6081919284BA1` PRIMARY KEY (parent_id);


-- ==========================================
-- Table: lr_extension_link
-- Created: 2014-11-25 03:45:06.630000
-- Modified: 2014-11-25 03:45:06.630000
-- ==========================================

CREATE TABLE lr_extension_link (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `parent_class` VARCHAR(255) NOT NULL,
    `child_class` VARCHAR(255) NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_extension_link
    ADD CONSTRAINT `PK__lr_exten__3213E83F7F73E9EC` PRIMARY KEY (id);

CREATE UNIQUE INDEX `UQ__lr_exten__0EC99930AAD3FD41` ON lr_extension_link (parent_class);
CREATE UNIQUE INDEX `UQ__lr_exten__E5D6DD2CD39A8F92` ON lr_extension_link (child_class);


-- ==========================================
-- Table: lr_fee_rate
-- Created: 2015-05-24 15:15:12.800000
-- Modified: 2015-05-24 15:15:12.957000
-- ==========================================

CREATE TABLE lr_fee_rate (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `fee_name` DECIMAL(19,0) NOT NULL,
    `transaction_type` DECIMAL(19,0) NULL,
    `area` DECIMAL(19,0) NULL,
    `size` DECIMAL(19,2) NULL,
    `measuremente_unit_type` DECIMAL(19,0) NULL,
    `location` DECIMAL(19,0) NULL,
    `land_use_type_category` DECIMAL(19,0) NULL,
    `land_use_type` DECIMAL(19,0) NULL,
    `size_range_upper_bound` DECIMAL(19,2) NULL,
    `size_range_lower_bound` DECIMAL(19,2) NULL,
    `size_range_type` DECIMAL(19,0) NULL,
    `rate_type` DECIMAL(19,0) NULL,
    `rate` DECIMAL(19,2) NULL,
    `id_fee_structure` DECIMAL(19,0) NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_fee_rate
    ADD CONSTRAINT `PK__lr_fee_r__3214EC0740E4E9B0` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_fee_structure
-- Created: 2015-05-24 15:15:12.860000
-- Modified: 2015-05-24 15:15:12.947000
-- ==========================================

CREATE TABLE lr_fee_structure (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `fee_name` DECIMAL(19,0) NOT NULL,
    `is_transaction_type` TINYINT NULL,
    `is_property_area` TINYINT NULL,
    `is_property_size` TINYINT NULL,
    `is_property_location` TINYINT NULL,
    `is_property_land_use_type_category` TINYINT NULL,
    `is_property_land_use_type` TINYINT NULL,
    `is_size_range` TINYINT NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_fee_structure
    ADD CONSTRAINT `PK__lr_fee_s__3214EC07C1C690CC` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_formfield
-- Created: 2014-11-25 03:45:06.633000
-- Modified: 2014-11-25 03:45:06.633000
-- ==========================================

CREATE TABLE lr_formfield (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `form_name` VARCHAR(64) NOT NULL,
    `class_name` VARCHAR(64) NOT NULL,
    `attribute_name` VARCHAR(64) NOT NULL,
    `xsd_type` VARCHAR(64) NOT NULL,
    `data_length` INT NULL,
    `caption` VARCHAR(128) NULL,
    `mandatory` TINYINT NULL,
    `category` VARCHAR(64) NULL,
    `mru` TINYINT NULL,
    `format` VARCHAR(255) NULL,
    `format_sample` VARCHAR(64) NULL,
    `attribute_precision` INT NULL,
    `enabled_for` VARCHAR(255) NULL,
    `readonly_for` VARCHAR(255) NULL,
    `validation_rule` VARCHAR(255) NULL,
    `condition_rule` VARCHAR(1500) NULL,
    `multiline` TINYINT NULL,
    `language` VARCHAR(5) NULL,
    `monolingual` TINYINT NULL,
    `group_name` VARCHAR(255) NULL,
    `ins_position` VARCHAR(1) NULL,
    `description` VARCHAR(512) NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_formfield
    ADD CONSTRAINT `PK__lr_formf__3214EC074D9924A0` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_ground_rent
-- Created: 2014-11-25 03:45:06.637000
-- Modified: 2014-11-25 03:45:06.637000
-- ==========================================

CREATE TABLE lr_ground_rent (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `propertyNumber` VARCHAR(50) NOT NULL,
    `paidYear` VARCHAR(10) NOT NULL,
    `amount` DOUBLE NULL,
    `paidSum` DOUBLE NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_ground_rent
    ADD CONSTRAINT `PK__lr_groun__3214EC07A1DE2703` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_incoming_document
-- Created: 2014-11-25 03:45:06.637000
-- Modified: 2014-11-25 03:45:07.063000
-- ==========================================

CREATE TABLE lr_incoming_document (
    `id` DECIMAL(19,0) NOT NULL,
    `establish_right` TINYINT NULL
);

ALTER TABLE lr_incoming_document
    ADD CONSTRAINT `PK__lr_incom__3213E83F1483D54A` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_individual
-- Created: 2014-11-25 03:45:06.640000
-- Modified: 2014-11-25 03:45:27.160000
-- ==========================================

CREATE TABLE lr_individual (
    `id` DECIMAL(19,0) NOT NULL,
    `first_name` VARCHAR(150) NULL,
    `second_name` VARCHAR(150) NULL,
    `last_name` VARCHAR(150) NULL,
    `last_name2` VARCHAR(150) NULL,
    `gender` DECIMAL(19,0) NOT NULL,
    `salutation` DECIMAL(19,0) NOT NULL,
    `civil_state` DECIMAL(19,0) NOT NULL,
    `profession` DECIMAL(19,0) NOT NULL,
    `occupation` VARCHAR(50) NULL,
    `clan_name` VARCHAR(30) NULL,
    `father_name` VARCHAR(50) NULL,
    `grandfather_name` VARCHAR(50) NULL,
    `paye_number` VARCHAR(50) NULL,
    `indiv1` VARCHAR(50) NULL,
    `indiv2` VARCHAR(50) NULL,
    `indiv_dict1` DECIMAL(19,0) NOT NULL,
    `indiv_dict2` DECIMAL(19,0) NOT NULL,
    `driver_licence_region` DECIMAL(19,0) NOT NULL,
    `driver_licence_number` VARCHAR(20) NULL
);

ALTER TABLE lr_individual
    ADD CONSTRAINT `PK__lr_indiv__3213E83F63DE9CA8` PRIMARY KEY (id);

CREATE INDEX `lr_individual_gender_idx` ON lr_individual (gender);
CREATE INDEX `lr_individual_last_name_idx` ON lr_individual (last_name);


-- ==========================================
-- Table: lr_launit
-- Created: 2014-11-25 03:45:06.643000
-- Modified: 2014-11-25 03:45:27.173000
-- ==========================================

CREATE TABLE lr_launit (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `unit_uid` VARCHAR(50) NULL,
    `old_property_id` VARCHAR(50) NULL,
    `tenure_type` DECIMAL(19,0) NOT NULL,
    `name` VARCHAR(250) NULL,
    `rental_amount` DOUBLE NULL,
    `build_value` DOUBLE NULL,
    `build_term` INT NULL,
    `register_type` VARCHAR(100) NULL,
    `purpose_clause` VARCHAR(50) NULL,
    `reg_date` DATETIME NULL,
    `volumefolio` VARCHAR(50) NULL,
    `cert_numbers` VARCHAR(1500) NULL,
    `is_exists` TINYINT NULL,
    `legal_description` VARCHAR(2000) NULL,
    `note` VARCHAR(2000) NULL,
    `transaction_cancel` VARCHAR(50) NULL,
    `archive_date` DATETIME NULL,
    `lau_date1` DATETIME NULL,
    `lau_date2` DATETIME NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL
);

ALTER TABLE lr_launit
    ADD CONSTRAINT `PK__lr_launi__3213E83FC450E627` PRIMARY KEY (id);

CREATE INDEX `lr_launit_old_property_id_idx` ON lr_launit (old_property_id);
CREATE INDEX `lr_launit_unit_uid_idx` ON lr_launit (unit_uid);
CREATE INDEX `lr_launit_version_idx` ON lr_launit (version);


-- ==========================================
-- Table: lr_launit_lineage
-- Created: 2014-11-25 03:45:06.647000
-- Modified: 2014-11-25 03:45:06.647000
-- ==========================================

CREATE TABLE lr_launit_lineage (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `child_id` DECIMAL(19,0) NULL,
    `parent_id` DECIMAL(19,0) NULL,
    `child_uid` VARCHAR(50) NULL,
    `parent_uid` VARCHAR(50) NOT NULL,
    `transaction_number` VARCHAR(50) NULL,
    `transaction_cancel` VARCHAR(50) NULL,
    `archive_date` DATETIME NULL
);

ALTER TABLE lr_launit_lineage
    ADD CONSTRAINT `PK__lr_launi__3213E83F20D0C9B3` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_launit_spatial_unit
-- Created: 2014-11-25 03:45:06.647000
-- Modified: 2014-11-25 03:45:27.143000
-- ==========================================

CREATE TABLE lr_launit_spatial_unit (
    `launit` DECIMAL(19,0) NOT NULL,
    `spatial_unit` DECIMAL(19,0) NOT NULL,
    `unit_index` INT NOT NULL
);

ALTER TABLE lr_launit_spatial_unit
    ADD CONSTRAINT `PK__lr_launi__8878425080DF12A1` PRIMARY KEY (launit, unit_index);

CREATE INDEX `lr_launit_spatial_unit__idx` ON lr_launit_spatial_unit (launit, spatial_unit);


-- ==========================================
-- Table: lr_mc_job
-- Created: 2014-11-25 03:45:06.650000
-- Modified: 2014-11-25 03:45:06.650000
-- ==========================================

CREATE TABLE lr_mc_job (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `job_instance_id` DECIMAL(19,0) NOT NULL,
    `job_id` DECIMAL(19,0) NOT NULL,
    `job_priority` DECIMAL(19,0) NOT NULL,
    `job_name` VARCHAR(250) NULL,
    `job_status` INT NULL,
    `job_started` DATETIME NULL,
    `job_updated` DATETIME NULL,
    `job_ended` DATETIME NULL,
    `job_comments` VARCHAR(800) NULL,
    `job_parameters` VARCHAR(2000) NULL,
    `transaction_id` DECIMAL(19,0) NOT NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_mc_job
    ADD CONSTRAINT `PK__lr_mc_jo__3214EC073C646992` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_mortgage
-- Created: 2014-11-25 03:45:06.650000
-- Modified: 2014-11-25 03:45:07.097000
-- ==========================================

CREATE TABLE lr_mortgage (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `amount` DOUBLE NULL,
    `interest_rate` DOUBLE NULL,
    `ranking` INT NULL,
    `mortgage_type` DECIMAL(19,0) NOT NULL,
    `mrg1` VARCHAR(50) NULL,
    `mrg2` VARCHAR(50) NULL,
    `mrg_dict1` DECIMAL(19,0) NOT NULL,
    `mrg_dict2` DECIMAL(19,0) NOT NULL,
    `party` DECIMAL(19,0) NULL,
    `right_id` DECIMAL(19,0) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL
);

ALTER TABLE lr_mortgage
    ADD CONSTRAINT `PK__lr_mortg__3213E83F2408E413` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_parcel
-- Created: 2014-11-25 03:45:06.653000
-- Modified: 2014-11-25 03:45:27.223000
-- ==========================================

CREATE TABLE lr_parcel (
    `id` DECIMAL(19,0) NOT NULL,
    `actual_use_type` DECIMAL(19,0) NOT NULL,
    `land_type` DECIMAL(19,0) NULL,
    `land_category` DECIMAL(19,0) NOT NULL,
    `land_purpose` DECIMAL(19,0) NOT NULL,
    `survey_plan_no` VARCHAR(50) NULL,
    `survey_type` DECIMAL(19,0) NOT NULL,
    `survey_date` DATETIME NULL,
    `parcel_number` VARCHAR(4) NULL,
    `survey_name` VARCHAR(32) NULL,
    `boundaries_description` VARCHAR(800) NULL,
    `adjacents` VARCHAR(500) NULL,
    `use_typespecific` VARCHAR(50) NULL,
    `parc1` VARCHAR(50) NULL,
    `parc2` VARCHAR(50) NULL,
    `parc_dict1` DECIMAL(19,0) NOT NULL,
    `parc_dict2` DECIMAL(19,0) NOT NULL,
    `parc_date1` DATETIME NULL,
    `parc_date2` DATETIME NULL,
    `parc_count1` INT NULL,
    `parc_count2` INT NULL
);

ALTER TABLE lr_parcel
    ADD CONSTRAINT `PK__lr_parce__3213E83F249FA76D` PRIMARY KEY (id);

CREATE INDEX `lr_parcel_actual_use_type_idx` ON lr_parcel (actual_use_type);


-- ==========================================
-- Table: lr_party
-- Created: 2014-11-25 03:45:06.653000
-- Modified: 2015-05-24 15:15:12.873000
-- ==========================================

CREATE TABLE lr_party (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `party_type` DECIMAL(19,0) NOT NULL,
    `party_role_type` DECIMAL(19,0) NOT NULL,
    `name` VARCHAR(250) NULL,
    `name2` VARCHAR(250) NULL,
    `person` DECIMAL(19,0) NULL,
    `share_nominator` INT NULL,
    `share_denominator` INT NULL,
    `share_description` VARCHAR(250) NULL,
    `shares` VARCHAR(255) NULL,
    `share_type` DECIMAL(19,0) NOT NULL,
    `tax_exempt` TINYINT NULL,
    `title_holder` TINYINT NULL,
    `cert_no` VARCHAR(100) NULL,
    `unit_uid` VARCHAR(500) NULL,
    `ruid` DECIMAL(19,0) NULL,
    `part1` VARCHAR(50) NULL,
    `part2` VARCHAR(50) NULL,
    `part_dict1` DECIMAL(19,0) NOT NULL,
    `part_dict2` DECIMAL(19,0) NOT NULL,
    `comments` VARCHAR(800) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL,
    `previous_id` DECIMAL(19,0) NULL
);

ALTER TABLE lr_party
    ADD CONSTRAINT `PK__lr_party__3213E83F3329FD78` PRIMARY KEY (id);

CREATE INDEX `lr_party_name_idx` ON lr_party (name);
CREATE INDEX `lr_party_party_role_type_idx` ON lr_party (party_role_type);
CREATE INDEX `lr_party_party_type_idx` ON lr_party (party_type);
CREATE INDEX `lr_party_person_idx` ON lr_party (person);


-- ==========================================
-- Table: lr_party_contact
-- Created: 2014-11-25 03:45:06.657000
-- Modified: 2014-11-25 03:45:27.157000
-- ==========================================

CREATE TABLE lr_party_contact (
    `contact` DECIMAL(19,0) NOT NULL,
    `party` DECIMAL(19,0) NOT NULL,
    `contact_index` INT NOT NULL
);

ALTER TABLE lr_party_contact
    ADD CONSTRAINT `PK__lr_party__835BE61CC799B8F9` PRIMARY KEY (contact, contact_index);

CREATE INDEX `lr_party_contact__idx` ON lr_party_contact (party, contact);


-- ==========================================
-- Table: lr_party_ext
-- Created: 2014-11-25 03:45:06.657000
-- Modified: 2014-11-25 03:45:06.657000
-- ==========================================

CREATE TABLE lr_party_ext (
    `parent_id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `extended_comments` VARCHAR(2000) NULL,
    `extended_params` VARCHAR(1000) NULL
);

ALTER TABLE lr_party_ext
    ADD CONSTRAINT `PK__lr_party__F2A608195B937354` PRIMARY KEY (parent_id);


-- ==========================================
-- Table: lr_party_group
-- Created: 2014-11-25 03:45:06.660000
-- Modified: 2014-11-25 03:45:07.133000
-- ==========================================

CREATE TABLE lr_party_group (
    `id` DECIMAL(19,0) NOT NULL,
    `group_type` DECIMAL(19,0) NOT NULL,
    `address` DECIMAL(19,0) NULL,
    `fax` VARCHAR(64) NULL,
    `email` VARCHAR(64) NULL,
    `phone1_number` VARCHAR(20) NULL,
    `phone1_extension` VARCHAR(5) NULL,
    `phone1_type` DECIMAL(19,0) NOT NULL,
    `phone2_number` VARCHAR(20) NULL,
    `phone2_extension` VARCHAR(5) NULL,
    `phone2_type` DECIMAL(19,0) NOT NULL,
    `phone3_number` VARCHAR(20) NULL,
    `phone3_extension` VARCHAR(5) NULL,
    `phone3_type` DECIMAL(19,0) NOT NULL
);

ALTER TABLE lr_party_group
    ADD CONSTRAINT `PK__lr_party__3213E83FDE1B35C5` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_party_launit
-- Created: 2014-11-25 03:45:06.660000
-- Modified: 2014-11-25 03:45:07.130000
-- ==========================================

CREATE TABLE lr_party_launit (
    `id` DECIMAL(19,0) NOT NULL,
    `launit` DECIMAL(19,0) NOT NULL
);

ALTER TABLE lr_party_launit
    ADD CONSTRAINT `PK__lr_party__3213E83F9B2A5181` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_party_member
-- Created: 2014-11-25 03:45:06.663000
-- Modified: 2014-11-25 03:45:27.160000
-- ==========================================

CREATE TABLE lr_party_member (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `share_nominator` INT NULL,
    `share_denominator` INT NULL,
    `party_ref` DECIMAL(19,0) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `group_ref` DECIMAL(19,0) NULL,
    `member_index` INT NULL
);

ALTER TABLE lr_party_member
    ADD CONSTRAINT `PK__lr_party__3213E83F7AC1E488` PRIMARY KEY (id);

CREATE INDEX `lr_party_member__idx` ON lr_party_member (group_ref, party_ref);


-- ==========================================
-- Table: lr_payment
-- Created: 2014-11-25 03:45:06.667000
-- Modified: 2014-11-25 03:45:27.243000
-- ==========================================

CREATE TABLE lr_payment (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `transaction_number` VARCHAR(50) NULL,
    `is_paid` TINYINT NULL,
    `invoice_number` VARCHAR(50) NULL,
    `receipt_number` DECIMAL(19,0) NULL,
    `payment_type` DECIMAL(19,0) NOT NULL,
    `payment_date` DATETIME NULL,
    `payment_status` DECIMAL(19,0) NOT NULL,
    `receipt_no` VARCHAR(30) NULL,
    `internal_receipt_no` VARCHAR(30) NULL,
    `bank_type` DECIMAL(19,0) NOT NULL,
    `bank_name` VARCHAR(50) NULL,
    `account_name` VARCHAR(50) NULL,
    `account_number` VARCHAR(30) NULL,
    `paid_sum` DOUBLE NULL,
    `balance_owed` DOUBLE NULL,
    `penalty` DOUBLE NULL,
    `paid_year` INT NULL,
    `create_date` DATETIME NULL,
    `begin_date` DATETIME NULL,
    `end_date` DATETIME NULL,
    `pay_period_year` INT NULL,
    `pay_period_month` INT NULL,
    `comments` VARCHAR(800) NULL,
    `pm1` VARCHAR(50) NULL,
    `pm2` VARCHAR(50) NULL,
    `pm_dict1` DECIMAL(19,0) NOT NULL,
    `pm_dict2` DECIMAL(19,0) NOT NULL,
    `pm_date1` DATETIME NULL,
    `pm_date2` DATETIME NULL,
    `pm_count1` INT NULL,
    `pm_count2` INT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `batch_id` DECIMAL(19,0) NULL,
    `batch_index` INT NULL
);

ALTER TABLE lr_payment
    ADD CONSTRAINT `PK__lr_payme__3213E83F6EBBDB06` PRIMARY KEY (id);

CREATE INDEX `lr_payment_payment_type_idx` ON lr_payment (payment_type);
CREATE INDEX `lr_payment_tr_number_idx` ON lr_payment (transaction_number);


-- ==========================================
-- Table: lr_payment_transaction
-- Created: 2014-11-25 03:45:06.670000
-- Modified: 2014-11-25 03:45:27.250000
-- ==========================================

CREATE TABLE lr_payment_transaction (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `calculated_fee` DOUBLE NULL,
    `manual_fee` DOUBLE NULL,
    `transaction_params` VARCHAR(2000) NULL,
    `receipt_no` VARCHAR(30) NULL,
    `payment_type` DECIMAL(19,0) NOT NULL,
    `payment_date` DATETIME NULL,
    `bank_type` DECIMAL(19,0) NOT NULL,
    `bank_name` VARCHAR(50) NULL,
    `account_name` VARCHAR(50) NULL,
    `account_number` VARCHAR(30) NULL,
    `paid_sum` DOUBLE NULL,
    `penalty` DOUBLE NULL,
    `paid_year` INT NULL,
    `pay_transaction_id` DOUBLE NULL,
    `transaction_code` VARCHAR(50) NULL,
    `create_date` DATETIME NULL,
    `begin_date` DATETIME NULL,
    `end_date` DATETIME NULL,
    `pay_period_year` INT NULL,
    `pay_period_month` INT NULL,
    `comments` VARCHAR(800) NULL,
    `pmt1` VARCHAR(50) NULL,
    `pmt2` VARCHAR(50) NULL,
    `pmt_dict1` DECIMAL(19,0) NOT NULL,
    `pmt_dict2` DECIMAL(19,0) NOT NULL,
    `pmt_date1` DATETIME NULL,
    `pmt_date2` DATETIME NULL,
    `pmt_count1` INT NULL,
    `pmt_count2` INT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `demandnotice_number` VARCHAR(12) NULL,
    `property_number` VARCHAR(255) NULL,
    `payment` DECIMAL(19,0) NULL,
    `payment_index` INT NULL,
    `transaction_id` DECIMAL(19,0) NULL,
    `transaction_index` INT NULL
);

ALTER TABLE lr_payment_transaction
    ADD CONSTRAINT `PK__lr_payme__3213E83F0C01EDE0` PRIMARY KEY (id);

CREATE INDEX `lr_payment_transaction_payment_id_idx` ON lr_payment_transaction (payment);
CREATE INDEX `lr_payment_transaction_payment_type_id_idx` ON lr_payment_transaction (payment_type);
CREATE INDEX `lr_payment_transaction_transaction_id_idx` ON lr_payment_transaction (transaction_id);


-- ==========================================
-- Table: lr_person
-- Created: 2014-11-25 03:45:06.670000
-- Modified: 2014-11-25 03:45:27.160000
-- ==========================================

CREATE TABLE lr_person (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `address` DECIMAL(19,0) NULL,
    `person_type` DECIMAL(19,0) NOT NULL,
    `person_id_type` DECIMAL(19,0) NOT NULL,
    `person_id_number` VARCHAR(64) NULL,
    `person_id_date` DATETIME NULL,
    `person_id_issue` VARCHAR(255) NULL,
    `tin` VARCHAR(50) NULL,
    `fax` VARCHAR(64) NULL,
    `email` VARCHAR(64) NULL,
    `phone1_number` VARCHAR(20) NULL,
    `phone1_extension` VARCHAR(5) NULL,
    `phone1_type` DECIMAL(19,0) NOT NULL,
    `phone2_number` VARCHAR(20) NULL,
    `phone2_extension` VARCHAR(5) NULL,
    `phone2_type` DECIMAL(19,0) NOT NULL,
    `phone3_number` VARCHAR(20) NULL,
    `phone3_extension` VARCHAR(5) NULL,
    `phone3_type` DECIMAL(19,0) NOT NULL,
    `birth_date` DATETIME NULL,
    `pers1` VARCHAR(50) NULL,
    `pers2` VARCHAR(50) NULL,
    `pers_dict1` DECIMAL(19,0) NOT NULL,
    `pers_dict2` DECIMAL(19,0) NOT NULL,
    `pers_cost1` DOUBLE NULL,
    `pers_cost2` DOUBLE NULL,
    `pers_count1` INT NULL,
    `pers_count2` INT NULL,
    `pers_date1` DATETIME NULL,
    `pers_date2` DATETIME NULL,
    `is_submiter` TINYINT NULL,
    `submiter` VARCHAR(800) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL
);

ALTER TABLE lr_person
    ADD CONSTRAINT `PK__lr_perso__3213E83F03860C09` PRIMARY KEY (id);

CREATE INDEX `lr_person_address_idx` ON lr_person (address);
CREATE INDEX `lr_person_id_number_idx` ON lr_person (person_id_number);
CREATE INDEX `lr_person_person_type_idx` ON lr_person (person_type);


-- ==========================================
-- Table: lr_process_event
-- Created: 2014-11-25 03:45:06.673000
-- Modified: 2014-11-25 03:45:07.173000
-- ==========================================

CREATE TABLE lr_process_event (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `event_type` DECIMAL(19,0) NOT NULL,
    `event_date` DATETIME NULL,
    `description` VARCHAR(800) NULL,
    `actor` VARCHAR(50) NULL,
    `history` DECIMAL(19,0) NULL,
    `event_index` INT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_process_event
    ADD CONSTRAINT `PK__lr_proce__3213E83F41788082` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_process_history
-- Created: 2014-11-25 03:45:06.677000
-- Modified: 2014-11-25 03:45:07.170000
-- ==========================================

CREATE TABLE lr_process_history (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `process_id` DECIMAL(19,0) NULL,
    `process_name` VARCHAR(255) NULL,
    `task_id` DECIMAL(19,0) NULL,
    `task_name` VARCHAR(255) NULL,
    `task_description` VARCHAR(255) NULL,
    `task_create` DATETIME NULL,
    `task_complete` DATETIME NULL,
    `task_transition` VARCHAR(255) NULL,
    `actor` VARCHAR(255) NULL,
    `duration` DECIMAL(19,0) NULL,
    `transaction_id` DECIMAL(19,0) NULL
);

ALTER TABLE lr_process_history
    ADD CONSTRAINT `PK__lr_proce__3213E83F4F3D1062` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_registry
-- Created: 2014-11-25 03:45:06.677000
-- Modified: 2014-11-25 03:45:06.677000
-- ==========================================

CREATE TABLE lr_registry (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `code` VARCHAR(32) NOT NULL,
    `description` VARCHAR(255) NOT NULL,
    `lodgment_class` VARCHAR(255) NOT NULL,
    `transaction_class` VARCHAR(255) NOT NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_registry
    ADD CONSTRAINT `PK__lr_regis__3214EC07D4E590EB` PRIMARY KEY (Id);

CREATE UNIQUE INDEX `UQ__lr_regis__357D4CF92C7E14C1` ON lr_registry (code);
CREATE UNIQUE INDEX `UQ__lr_regis__489B0D977FBCB163` ON lr_registry (description);


-- ==========================================
-- Table: lr_registry_office
-- Created: 2014-11-25 03:45:06.733000
-- Modified: 2014-11-25 03:45:06.997000
-- ==========================================

CREATE TABLE lr_registry_office (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `string_code` VARCHAR(10) NULL,
    `digital_code` INT NULL,
    `office_name` VARCHAR(100) NULL,
    `office_type` VARCHAR(100) NULL,
    `address` VARCHAR(255) NULL,
    `head_name` VARCHAR(100) NULL,
    `phone` VARCHAR(255) NULL,
    `fax` VARCHAR(64) NULL,
    `email` VARCHAR(64) NULL,
    `web_site` VARCHAR(255) NULL,
    `main` TINYINT NULL,
    `active` TINYINT NULL,
    `comments` VARCHAR(800) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_registry_office
    ADD CONSTRAINT `PK__lr_regis__3213E83F79119EDB` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_rejection
-- Created: 2014-11-25 03:45:06.733000
-- Modified: 2014-11-25 03:45:07.173000
-- ==========================================

CREATE TABLE lr_rejection (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `rejection_date` DATETIME NULL,
    `comments` DATETIME NULL,
    `lodgment_id` DECIMAL(19,0) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_rejection
    ADD CONSTRAINT `PK__lr_rejec__3213E83F2E2923E3` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_rejection_reason
-- Created: 2014-11-25 03:45:06.737000
-- Modified: 2014-11-25 03:45:07.177000
-- ==========================================

CREATE TABLE lr_rejection_reason (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `reason_type` DECIMAL(19,0) NOT NULL,
    `comments` VARCHAR(2000) NULL,
    `rejection_id` DECIMAL(19,0) NULL,
    `rejection_index` INT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_rejection_reason
    ADD CONSTRAINT `PK__lr_rejec__3213E83FA19DCB55` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_rental_amount_revision
-- Created: 2015-05-24 15:15:12.893000
-- Modified: 2015-05-24 15:15:12.893000
-- ==========================================

CREATE TABLE lr_rental_amount_revision (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `effective_date` DATETIME NOT NULL,
    `annual_rental_amount` DOUBLE NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `property_number` VARCHAR(50) NOT NULL
);

ALTER TABLE lr_rental_amount_revision
    ADD CONSTRAINT `PK__lr_renta__3213E83F853A5855` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_replicationcontent
-- Created: 2014-11-25 03:45:06.737000
-- Modified: 2014-11-25 03:45:07.177000
-- ==========================================

CREATE TABLE lr_replicationcontent (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `node_path` VARCHAR(254) NOT NULL,
    `parent_path` VARCHAR(254) NOT NULL,
    `package` DECIMAL(19,0) NULL,
    `create_date` DATETIME NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_replicationcontent
    ADD CONSTRAINT `PK__lr_repli__3213E83F576F6D6D` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_replicationlog
-- Created: 2014-11-25 03:45:06.740000
-- Modified: 2014-11-25 03:45:07.180000
-- ==========================================

CREATE TABLE lr_replicationlog (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `package` DECIMAL(19,0) NULL,
    `batch_id` DECIMAL(19,0) NOT NULL,
    `entity_id` DECIMAL(19,0) NOT NULL,
    `entity_classname` VARCHAR(128) NOT NULL,
    `logged_at` DATETIME NOT NULL,
    `uploaded_at` DATETIME NULL,
    `uploaded` TINYINT NULL,
    `repeat_number` INT NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_replicationlog
    ADD CONSTRAINT `PK__lr_repli__3213E83F9A390E42` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_replicationpackage
-- Created: 2014-11-25 03:45:06.740000
-- Modified: 2014-11-25 03:45:07.183000
-- ==========================================

CREATE TABLE lr_replicationpackage (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `package_name` VARCHAR(128) NOT NULL,
    `status` DECIMAL(19,0) NOT NULL,
    `modify_date` DATETIME NOT NULL,
    `create_date` DATETIME NOT NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_replicationpackage
    ADD CONSTRAINT `PK__lr_repli__3213E83F0096348A` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_rrr
-- Created: 2014-11-25 03:45:06.743000
-- Modified: 2015-05-24 15:15:12.953000
-- ==========================================

CREATE TABLE lr_rrr (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `rrr_type` DECIMAL(19,0) NOT NULL,
    `transaction_source` VARCHAR(50) NULL,
    `transaction_cancel` VARCHAR(50) NULL,
    `share_nominator` INT NULL,
    `share_denominator` INT NULL,
    `description` VARCHAR(1500) NULL,
    `TIME_spec` DATETIME NULL,
    `start_date` DATETIME NULL,
    `expiration_date` DATETIME NULL,
    `end_date` DATETIME NULL,
    `term_year` INT NULL,
    `term_month` INT NULL,
    `condition_approved_by` VARCHAR(100) NULL,
    `condition_approved_on` DATETIME NULL,
    `right1` VARCHAR(50) NULL,
    `right2` VARCHAR(50) NULL,
    `party` DECIMAL(19,0) NULL,
    `la_unit` DECIMAL(19,0) NULL,
    `create_date` DATETIME NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL,
    `pay_period_year` INT NULL,
    `term_day` INT NULL,
    `consideration` DOUBLE NULL,
    `consideration_currency` DECIMAL(19,0) NULL,
    `rental_amount` DOUBLE NULL,
    `build_value` DOUBLE NULL,
    `improvement_amount_currency` DECIMAL(19,0) NULL,
    `build_term` INT NULL,
    `security_number_1` VARCHAR(255) NULL,
    `security_number_2` VARCHAR(255) NULL
);

ALTER TABLE lr_rrr
    ADD CONSTRAINT `PK__lr_rrr__3213E83FECCA5743` PRIMARY KEY (id);

CREATE INDEX `lr_rrr__idx` ON lr_rrr (party, la_unit);
CREATE INDEX `lr_rrr_rrr_type_idx` ON lr_rrr (rrr_type);


-- ==========================================
-- Table: lr_rrr_billing
-- Created: 2014-11-25 03:45:06.747000
-- Modified: 2014-11-25 03:45:07.190000
-- ==========================================

CREATE TABLE lr_rrr_billing (
    `rrr` DECIMAL(19,0) NOT NULL,
    `billing` DECIMAL(19,0) NOT NULL,
    `rrr_index` INT NOT NULL
);

ALTER TABLE lr_rrr_billing
    ADD CONSTRAINT `PK__lr_rrr_b__C4D9FF94CD9E1150` PRIMARY KEY (rrr, rrr_index);


-- ==========================================
-- Table: lr_rrr_condition
-- Created: 2014-11-25 03:45:06.747000
-- Modified: 2014-11-25 03:45:07.193000
-- ==========================================

CREATE TABLE lr_rrr_condition (
    `rrr` DECIMAL(19,0) NOT NULL,
    `condition` DECIMAL(19,0) NOT NULL,
    `rrr_index` INT NOT NULL
);

ALTER TABLE lr_rrr_condition
    ADD CONSTRAINT `PK__lr_rrr_c__C4D9FF94E4A188D9` PRIMARY KEY (rrr, rrr_index);


-- ==========================================
-- Table: lr_rrr_deleted
-- Created: 2016-04-26 12:16:00.317000
-- Modified: 2016-04-26 12:16:00.317000
-- ==========================================

CREATE TABLE lr_rrr_deleted (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `rrr_type` DECIMAL(19,0) NOT NULL,
    `transaction_source` VARCHAR(50) NULL,
    `transaction_cancel` VARCHAR(50) NULL,
    `share_nominator` INT NULL,
    `share_denominator` INT NULL,
    `description` VARCHAR(1500) NULL,
    `TIME_spec` DATETIME NULL,
    `start_date` DATETIME NULL,
    `expiration_date` DATETIME NULL,
    `end_date` DATETIME NULL,
    `term_year` INT NULL,
    `term_month` INT NULL,
    `condition_approved_by` VARCHAR(100) NULL,
    `condition_approved_on` DATETIME NULL,
    `right1` VARCHAR(50) NULL,
    `right2` VARCHAR(50) NULL,
    `party` DECIMAL(19,0) NULL,
    `la_unit` DECIMAL(19,0) NULL,
    `create_date` DATETIME NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL,
    `pay_period_year` INT NULL,
    `term_day` INT NULL,
    `consideration` DOUBLE NULL,
    `consideration_currency` DECIMAL(19,0) NULL,
    `rental_amount` DOUBLE NULL,
    `build_value` DOUBLE NULL,
    `improvement_amount_currency` DECIMAL(19,0) NULL,
    `build_term` INT NULL,
    `security_number_1` VARCHAR(255) NULL,
    `security_number_2` VARCHAR(255) NULL
);


-- ==========================================
-- Table: lr_rrr_metadata
-- Created: 2014-11-25 03:45:06.757000
-- Modified: 2014-11-25 03:45:07.183000
-- ==========================================

CREATE TABLE lr_rrr_metadata (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `code` VARCHAR(64) NOT NULL,
    `label` VARCHAR(254) NOT NULL,
    `descr` VARCHAR(1000) NULL,
    `category` VARCHAR(64) NOT NULL,
    `general_term` TINYINT NULL,
    `sort_order` INT NULL,
    `hidden` TINYINT NULL,
    `rrr_type` INT NOT NULL,
    `action_type` INT NOT NULL,
    `can_expire` TINYINT NOT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_rrr_metadata
    ADD CONSTRAINT `PK__lr_rrr_m__3214EC077B723980` PRIMARY KEY (Id);

CREATE UNIQUE INDEX `UQ__lr_rrr_m__357D4CF9E0D16904` ON lr_rrr_metadata (code);


-- ==========================================
-- Table: lr_rrr_patched
-- Created: 2016-04-26 12:16:00.447000
-- Modified: 2016-04-26 12:16:00.447000
-- ==========================================

CREATE TABLE lr_rrr_patched (
    `id` DECIMAL(19,0) NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `rrr_type` DECIMAL(19,0) NOT NULL,
    `transaction_source` VARCHAR(50) NULL,
    `transaction_cancel` VARCHAR(50) NULL,
    `share_nominator` INT NULL,
    `share_denominator` INT NULL,
    `description` VARCHAR(1500) NULL,
    `TIME_spec` DATETIME NULL,
    `start_date` DATETIME NULL,
    `expiration_date` DATETIME NULL,
    `end_date` DATETIME NULL,
    `term_year` INT NULL,
    `term_month` INT NULL,
    `condition_approved_by` VARCHAR(100) NULL,
    `condition_approved_on` DATETIME NULL,
    `right1` VARCHAR(50) NULL,
    `right2` VARCHAR(50) NULL,
    `party` DECIMAL(19,0) NOT NULL,
    `la_unit` DECIMAL(19,0) NULL,
    `create_date` DATETIME NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL,
    `pay_period_year` INT NULL,
    `term_day` INT NULL,
    `consideration` DOUBLE NULL,
    `rental_amount` DOUBLE NULL,
    `build_value` DOUBLE NULL,
    `build_term` INT NULL,
    `security_number_1` VARCHAR(255) NULL,
    `security_number_2` VARCHAR(255) NULL,
    `consideration_currency` DECIMAL(19,0) NULL,
    `improvement_amount_currency` DECIMAL(19,0) NULL
);


-- ==========================================
-- Table: lr_setting
-- Created: 2014-11-25 03:45:06.760000
-- Modified: 2014-11-25 03:45:06.760000
-- ==========================================

CREATE TABLE lr_setting (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `category` VARCHAR(64) NOT NULL,
    `name` VARCHAR(150) NOT NULL,
    `value` VARCHAR(1000) NOT NULL,
    `description` VARCHAR(1000) NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_setting
    ADD CONSTRAINT `PK__lr_setti__3214EC07F68F69A0` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_simplecounter
-- Created: 2014-11-25 03:45:06.760000
-- Modified: 2014-11-25 03:45:07.250000
-- ==========================================

CREATE TABLE lr_simplecounter (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `counter` VARCHAR(255) NOT NULL,
    `value` DECIMAL(19,0) NOT NULL,
    `office_prefix` TINYINT NULL,
    `digital_prefix` TINYINT NULL,
    `digital_length` INT NOT NULL,
    `modify_date` DATETIME NULL,
    `with_rollback` TINYINT NULL,
    `own_prefix` VARCHAR(5) NULL,
    `reset_new_year` TINYINT NULL,
    `advance_config` VARCHAR(255) NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_simplecounter
    ADD CONSTRAINT `PK__lr_simpl__3214EC078A8550AE` PRIMARY KEY (Id);

CREATE UNIQUE INDEX `UQ__lr_simpl__28352C07C570BBE6` ON lr_simplecounter (counter);


-- ==========================================
-- Table: lr_simplecounter_pool
-- Created: 2014-11-25 03:45:06.763000
-- Modified: 2014-11-25 03:45:06.763000
-- ==========================================

CREATE TABLE lr_simplecounter_pool (
    `Id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `counter` VARCHAR(255) NOT NULL,
    `value` DECIMAL(19,0) NOT NULL,
    `ref_number` VARCHAR(255) NULL,
    `modify_date` DATETIME NULL,
    PRIMARY KEY (`Id`)
);

ALTER TABLE lr_simplecounter_pool
    ADD CONSTRAINT `PK__lr_simpl__3214EC0700F26B99` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_site_analysis
-- Created: 2014-11-25 03:45:06.767000
-- Modified: 2014-11-25 03:45:07.237000
-- ==========================================

CREATE TABLE lr_site_analysis (
    `Id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `neighbourhood` VARCHAR(50) NULL,
    `max_high_allow` DECIMAL(19,0) NULL,
    `devlopment_status` DECIMAL(19,0) NULL,
    `density` DECIMAL(19,0) NULL,
    `with_planning_schema` TINYINT NULL,
    `tps_nopta_number` VARCHAR(50) NULL,
    `max_area_development` DOUBLE NULL,
    `topography` DECIMAL(19,0) NULL,
    `soli_condition` DECIMAL(19,0) NULL,
    `access_road_status` DECIMAL(19,0) NULL,
    `hierachy_road` VARCHAR(50) NULL,
    `federal_road_access` TINYINT NULL,
    `access_road_width` DOUBLE NULL,
    `access_road_terminate` TINYINT NULL,
    `development_hinder_future_development` TINYINT NULL,
    `proximity_to_school` DOUBLE NULL,
    `proximity_to_hospital` DOUBLE NULL,
    `proximity_to_shop` DOUBLE NULL,
    `proximity_to_worship` DOUBLE NULL,
    `proximity_to_sportarena` DOUBLE NULL,
    `proximity_to_office` DOUBLE NULL,
    `proximity_to_industry` DOUBLE NULL,
    `proximity_to_other` DOUBLE NULL,
    `proximity_comment` VARCHAR(800) NULL,
    `proximity_to_utility` DOUBLE NULL,
    `proximity_to_electricity` DOUBLE NULL,
    `capacity` DOUBLE NULL,
    `proximity_to_Water` DOUBLE NULL,
    `proximity_to_nnpc` DOUBLE NULL,
    `proximity_to_telephone` DOUBLE NULL,
    `proximity_further_comment` VARCHAR(800) NULL,
    `distance_to_lake` DOUBLE NULL,
    `distance_to_mountain` DOUBLE NULL,
    `distance_to_quarry` DOUBLE NULL,
    `distance_to_river` DOUBLE NULL,
    `distance_to_gully` DOUBLE NULL,
    `distance_to_railway` DOUBLE NULL,
    `distance_to_expressway` DOUBLE NULL,
    `distance_to_others` DOUBLE NULL,
    `distance_to_feature_comment` VARCHAR(800) NULL,
    `setback_building1` DOUBLE NULL,
    `setback_building1_land_use` DECIMAL(19,0) NULL,
    `setback_building2` DOUBLE NULL,
    `setback_building2_land_use` DECIMAL(19,0) NULL,
    `setback_building3` DOUBLE NULL,
    `setback_building3_land_use` DECIMAL(19,0) NULL,
    `setback_building4` DOUBLE NULL,
    `setback_building4_land_use` DECIMAL(19,0) NULL,
    `setback_access_road` DOUBLE NULL,
    `setback_other_comment` VARCHAR(800) NULL,
    `household_utility_access` TINYINT NULL,
    `conformity_of_development` VARCHAR(50) NULL,
    `fencing_encourage` TINYINT NULL,
    `fencing_type` VARCHAR(50) NULL
);

ALTER TABLE lr_site_analysis
    ADD CONSTRAINT `PK__lr_site___3214EC075F13B6D1` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_source_document
-- Created: 2014-11-25 03:45:06.770000
-- Modified: 2014-12-05 02:35:58.927000
-- ==========================================

CREATE TABLE lr_source_document (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `document_number` VARCHAR(50) NULL,
    `ref_number` VARCHAR(50) NULL,
    `minute_number` VARCHAR(50) NULL,
    `document_type` DECIMAL(19,0) NOT NULL,
    `duplicate` TINYINT NULL,
    `access_type` DECIMAL(19,0) NOT NULL,
    `acceptance` DATETIME NULL,
    `recordation` DATETIME NULL,
    `submission` DATETIME NULL,
    `issued_by` VARCHAR(500) NULL,
    `page_count` INT NULL,
    `comments` VARCHAR(800) NULL,
    `create_date` DATETIME NULL,
    `modified_at` DATETIME NULL,
    `modified_by` VARCHAR(255) NULL,
    `property_file_page` VARCHAR(50) NULL,
    `sdoc1` VARCHAR(50) NULL,
    `sdoc2` VARCHAR(50) NULL,
    `sdoc_dict1` DECIMAL(19,0) NOT NULL,
    `sdoc_dict2` DECIMAL(19,0) NOT NULL,
    `sdoc_count1` INT NULL,
    `sdoc_count2` INT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL
);

ALTER TABLE lr_source_document
    ADD CONSTRAINT `PK__lr_sourc__3213E83F7D90E968` PRIMARY KEY (id);

CREATE INDEX `lr_source_document_document_number_idx` ON lr_source_document (document_number);
CREATE INDEX `lr_source_document_document_type_idx` ON lr_source_document (document_type);


-- ==========================================
-- Table: lr_spatial_unit
-- Created: 2014-11-25 03:45:06.773000
-- Modified: 2015-05-24 15:15:12.953000
-- ==========================================

CREATE TABLE lr_spatial_unit (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `suid` VARCHAR(50) NULL,
    `old_property_id` VARCHAR(50) NULL,
    `tenure_type` DECIMAL(19,0) NOT NULL,
    `label` VARCHAR(250) NULL,
    `note` VARCHAR(500) NULL,
    `comments` VARCHAR(800) NULL,
    `spatial_unit_type` DECIMAL(19,0) NOT NULL,
    `status` DECIMAL(19,0) NOT NULL,
    `property_kind` DECIMAL(19,0) NULL,
    `purpose` DECIMAL(19,0) NOT NULL,
    `zone` DECIMAL(19,0) NOT NULL,
    `layout` DECIMAL(19,0) NOT NULL,
    `block_name` VARCHAR(50) NULL,
    `refnum` VARCHAR(60) NULL,
    `upin` VARCHAR(30) NULL,
    `su_number` VARCHAR(30) NULL,
    `local_number` VARCHAR(30) NULL,
    `block_number` VARCHAR(50) NULL,
    `lot_number` VARCHAR(50) NULL,
    `plan_number` VARCHAR(40) NULL,
    `tracing_number` VARCHAR(32) NULL,
    `specific` VARCHAR(50) NULL,
    `volume` VARCHAR(20) NULL,
    `folio` VARCHAR(20) NULL,
    `volumefolio` VARCHAR(150) NULL,
    `is_exists` TINYINT NULL,
    `area` DOUBLE NULL,
    `area_unit_type` DECIMAL(19,0) NOT NULL,
    `area_planned` DOUBLE NULL,
    `areapl_unit_type` DECIMAL(19,0) NOT NULL,
    `area_buildings` DOUBLE NULL,
    `areabld_unit_type` DECIMAL(19,0) NOT NULL,
    `percent_covered` DOUBLE NULL,
    `balance_date` DATETIME NULL,
    `balance_sum` DOUBLE NULL,
    `spatial_value1` DOUBLE NULL,
    `spatial_date1` DATETIME NULL,
    `spatial_value2` DOUBLE NULL,
    `spatial_date2` DATETIME NULL,
    `rec1` VARCHAR(50) NULL,
    `rec2` VARCHAR(50) NULL,
    `rec_dict1` DECIMAL(19,0) NOT NULL,
    `rec_dict2` DECIMAL(19,0) NOT NULL,
    `cost1` DOUBLE NULL,
    `cost2` DOUBLE NULL,
    `count1` INT NULL,
    `count2` INT NULL,
    `spu_date` DATETIME NULL,
    `subdivision` VARCHAR(128) NULL,
    `transaction_cancel` VARCHAR(50) NULL,
    `archive_date` DATETIME NULL,
    `address` DECIMAL(19,0) NULL,
    `restrictions` VARCHAR(1500) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `source_id` DECIMAL(19,0) NULL,
    `SiteAnalysis` DECIMAL(19,0) NULL,
    `property_area` DECIMAL(19,0) NULL
);

ALTER TABLE lr_spatial_unit
    ADD CONSTRAINT `PK__lr_spati__3213E83F35C30A89` PRIMARY KEY (id);

CREATE INDEX `lr_spatial_unit_address_idx` ON lr_spatial_unit (address);
CREATE INDEX `lr_spatial_unit_old_property_id_idx` ON lr_spatial_unit (old_property_id);
CREATE INDEX `lr_spatial_unit_plannumber_idx` ON lr_spatial_unit (plan_number);
CREATE INDEX `lr_spatial_unit_suid_idx` ON lr_spatial_unit (suid);


-- ==========================================
-- Table: lr_spatial_unit_ext
-- Created: 2014-11-25 03:45:06.777000
-- Modified: 2014-11-25 03:45:06.777000
-- ==========================================

CREATE TABLE lr_spatial_unit_ext (
    `parent_id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `extended_comments` VARCHAR(2000) NULL,
    `extended_params` VARCHAR(1000) NULL
);

ALTER TABLE lr_spatial_unit_ext
    ADD CONSTRAINT `PK__lr_spati__F2A60819CC81EBFB` PRIMARY KEY (parent_id);


-- ==========================================
-- Table: lr_spatial_unit_member
-- Created: 2014-11-25 03:45:06.777000
-- Modified: 2014-11-25 03:45:27.227000
-- ==========================================

CREATE TABLE lr_spatial_unit_member (
    `parent_unit` DECIMAL(19,0) NOT NULL,
    `child_unit` DECIMAL(19,0) NOT NULL,
    `unit_index` INT NOT NULL
);

ALTER TABLE lr_spatial_unit_member
    ADD CONSTRAINT `PK__lr_spati__F489AF29F303A653` PRIMARY KEY (parent_unit, unit_index);

CREATE INDEX `lr_spatial_unit_member__idx` ON lr_spatial_unit_member (parent_unit, child_unit);


-- ==========================================
-- Table: lr_survey_plan
-- Created: 2015-05-24 15:15:12.910000
-- Modified: 2015-05-24 15:15:14.263000
-- ==========================================

CREATE TABLE lr_survey_plan (
    `Id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `plan_number` VARCHAR(40) NULL,
    `local_government_area` DECIMAL(19,0) NULL,
    `zone` DECIMAL(19,0) NOT NULL,
    `layout` DECIMAL(19,0) NOT NULL,
    `city` VARCHAR(100) NULL,
    `cell` VARCHAR(100) NULL,
    `ward` VARCHAR(100) NULL,
    `district_text` VARCHAR(100) NULL,
    `region` DECIMAL(19,0) NOT NULL,
    `country` DECIMAL(19,0) NOT NULL,
    `surveyor_plan_no` VARCHAR(50) NULL,
    `area` DOUBLE NULL,
    `area_unit_type` DECIMAL(19,0) NOT NULL,
    `survey_start_date` DATETIME NULL,
    `survey_end_date` DATETIME NULL,
    `surveyor_name` VARCHAR(32) NULL,
    `tracing_number` VARCHAR(32) NULL,
    `approval_date` DATETIME NULL,
    `survey_type` DECIMAL(19,0) NOT NULL,
    `plots_Amount` INT NOT NULL,
    `terrain_type` DECIMAL(19,0) NOT NULL,
    `beacon_amount_re_establish` INT NOT NULL,
    `beacon_amount_perimeter` INT NOT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `surveyor_type` DECIMAL(19,0) NOT NULL,
    `comments` VARCHAR(2000) NULL
);

ALTER TABLE lr_survey_plan
    ADD CONSTRAINT `PK__lr_surve__3214EC07D81925DA` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_taxation
-- Created: 2014-11-25 03:45:06.780000
-- Modified: 2014-11-25 03:45:07.247000
-- ==========================================

CREATE TABLE lr_taxation (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `tax_amount` DOUBLE NULL,
    `tax_type` DECIMAL(19,0) NOT NULL,
    `tax_date` DATETIME NULL,
    `comments` VARCHAR(800) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_taxation
    ADD CONSTRAINT `PK__lr_taxat__3213E83FDDF6B317` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_tempcounter
-- Created: 2014-11-25 03:45:06.780000
-- Modified: 2014-11-25 03:45:07.250000
-- ==========================================

CREATE TABLE lr_tempcounter (
    `Id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `counter` DECIMAL(19,0) NOT NULL,
    `value_text` VARCHAR(255) NOT NULL,
    `ref_number` VARCHAR(255) NULL,
    `transaction_id` DECIMAL(19,0) NULL,
    `transaction_index` INT NULL
);

ALTER TABLE lr_tempcounter
    ADD CONSTRAINT `PK__lr_tempc__3214EC076C6DB7D3` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_transaction
-- Created: 2014-11-25 03:45:06.783000
-- Modified: 2015-05-24 15:15:14.260000
-- ==========================================

CREATE TABLE lr_transaction (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `transaction_number` VARCHAR(50) NULL,
    `transaction_type` DECIMAL(19,0) NULL,
    `transaction_status` DECIMAL(19,0) NOT NULL,
    `transaction_source` DECIMAL(19,0) NOT NULL,
    `source_property_ids` VARCHAR(500) NULL,
    `target_property_ids` VARCHAR(500) NULL,
    `old_property_id` VARCHAR(50) NULL,
    `parent_property_ids` VARCHAR(500) NULL,
    `tenure_type` DECIMAL(19,0) NOT NULL,
    `is_search_oldfile` TINYINT NULL,
    `registration_fee` DOUBLE NULL,
    `consideration` DOUBLE NULL,
    `interest_money` DOUBLE NULL,
    `create_date` DATETIME NULL,
    `complete_date` DATETIME NULL,
    `start_date` DATETIME NULL,
    `expiration_date` DATETIME NULL,
    `sign_date` DATETIME NULL,
    `registration_date` DATETIME NULL,
    `application_date` DATETIME NULL,
    `firstpay_date` DATETIME NULL,
    `balance_date` DATETIME NULL,
    `balance_sum` DOUBLE NULL,
    `partial` TINYINT NULL,
    `pageNumber` VARCHAR(16) NULL,
    `cert_nos` VARCHAR(255) NULL,
    `term_year` INT NULL,
    `term_month` INT NULL,
    `term_year_ext` INT NULL,
    `term_month_ext` INT NULL,
    `lease_extension` DECIMAL(19,0) NOT NULL,
    `lease_duration` DECIMAL(19,0) NOT NULL,
    `duration` INT NULL,
    `build_term` INT NULL,
    `build_value` DOUBLE NULL,
    `pay_period_year` INT NULL,
    `pay_period_month` INT NULL,
    `volume` VARCHAR(20) NULL,
    `folio` VARCHAR(20) NULL,
    `volume_linked` VARCHAR(20) NULL,
    `folio_linked` VARCHAR(20) NULL,
    `recordingno` VARCHAR(30) NULL,
    `internal_receipt_no` VARCHAR(30) NULL,
    `serial_number` VARCHAR(30) NULL,
    `general_number` VARCHAR(50) NULL,
    `related_number` VARCHAR(50) NULL,
    `related_page_number` VARCHAR(50) NULL,
    `related_volume` VARCHAR(50) NULL,
    `deed_case` DECIMAL(19,0) NOT NULL,
    `related_instr_number` VARCHAR(50) NULL,
    `lodgment_number` VARCHAR(50) NULL,
    `boxno` VARCHAR(20) NULL,
    `special_condition` VARCHAR(50) NULL,
    `inscription` VARCHAR(800) NULL,
    `inscription2` VARCHAR(800) NULL,
    `reg_initials` VARCHAR(20) NULL,
    `blockplot` VARCHAR(200) NULL,
    `volumefolio` VARCHAR(150) NULL,
    `filetype` DECIMAL(19,0) NOT NULL,
    `region` DECIMAL(19,0) NOT NULL,
    `district` DECIMAL(19,0) NOT NULL,
    `is_delivered` TINYINT NULL,
    `is_right_required` TINYINT NULL,
    `is_inactive` TINYINT NULL,
    `is_mem_transaction` TINYINT NULL,
    `comments` VARCHAR(800) NULL,
    `site_analysis` VARCHAR(800) NULL,
    `inspection_officer` VARCHAR(50) NULL,
    `gis_params` VARCHAR(800) NULL,
    `tran1` VARCHAR(50) NULL,
    `tran2` VARCHAR(50) NULL,
    `tran_date1` DATETIME NULL,
    `tran_date2` DATETIME NULL,
    `tran_dict1` DECIMAL(19,0) NOT NULL,
    `tran_dict2` DECIMAL(19,0) NOT NULL,
    `tran_cost1` DOUBLE NULL,
    `tran_cost2` DOUBLE NULL,
    `tran_count1` INT NULL,
    `tran_count2` INT NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `demandnotice_number` VARCHAR(12) NULL,
    `batch` DECIMAL(19,0) NULL,
    `transaction_index` INT NULL,
    `term_day` INT NULL,
    `consideration_currency` DECIMAL(19,0) NULL,
    `temp_consideration` VARCHAR(30) NULL,
    `improvement_amount_currency` DECIMAL(19,0) NULL,
    `data_corrected_transaction_number` VARCHAR(50) NULL,
    `data_corrected_transaction_type` DECIMAL(19,0) NULL,
    `data_corrected_comments` VARCHAR(800) NULL,
    `data_corrected_create_date` DATETIME NULL,
    `data_corrected_complete_date` DATETIME NULL,
    `recommendation_memorandum` VARCHAR(800) NULL,
    `SurveyPlan` DECIMAL(19,0) NULL
);

ALTER TABLE lr_transaction
    ADD CONSTRAINT `PK__lr_trans__3213E83F7F929339` PRIMARY KEY (id);

CREATE INDEX `lr_transaction_batch_idx` ON lr_transaction (batch);
CREATE INDEX `lr_transaction_old_property_id_idx` ON lr_transaction (old_property_id);
CREATE INDEX `lr_transaction_registration_date_idx` ON lr_transaction (registration_date);
CREATE INDEX `lr_transaction_start_date_idx` ON lr_transaction (start_date);
CREATE INDEX `lr_transaction_transaction_source_idx` ON lr_transaction (transaction_source);
CREATE INDEX `lr_transaction_transaction_status_idx` ON lr_transaction (transaction_status);
CREATE INDEX `lr_transaction_transaction_type_idx` ON lr_transaction (transaction_type);
CREATE INDEX `lr_transaction_volumefolio_idx` ON lr_transaction (volume, folio);


-- ==========================================
-- Table: lr_transaction_document
-- Created: 2014-11-25 03:45:06.787000
-- Modified: 2014-11-25 03:45:27.237000
-- ==========================================

CREATE TABLE lr_transaction_document (
    `transaction_id` DECIMAL(19,0) NOT NULL,
    `document_id` DECIMAL(19,0) NOT NULL,
    `document_index` INT NOT NULL
);

ALTER TABLE lr_transaction_document
    ADD CONSTRAINT `PK__lr_trans__37C7C1175599DCBD` PRIMARY KEY (transaction_id, document_index);

CREATE INDEX `lr_transaction_document__idx` ON lr_transaction_document (transaction_id, document_id);


-- ==========================================
-- Table: lr_transaction_ext
-- Created: 2014-11-25 03:45:06.790000
-- Modified: 2014-11-25 03:45:06.790000
-- ==========================================

CREATE TABLE lr_transaction_ext (
    `parent_id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `extended_comments` VARCHAR(2000) NULL,
    `extended_params` VARCHAR(1000) NULL,
    `NonExistingPropertiesSearch` VARCHAR(1000) NULL,
    `CountPropertiesSearch` DECIMAL(19,0) NULL
);

ALTER TABLE lr_transaction_ext
    ADD CONSTRAINT `PK__lr_trans__F2A60819F2BCC067` PRIMARY KEY (parent_id);


-- ==========================================
-- Table: lr_transaction_launit
-- Created: 2014-11-25 03:45:06.790000
-- Modified: 2014-11-25 03:45:27.237000
-- ==========================================

CREATE TABLE lr_transaction_launit (
    `transaction_id` DECIMAL(19,0) NOT NULL,
    `launit_id` DECIMAL(19,0) NOT NULL,
    `launit_index` INT NOT NULL
);

ALTER TABLE lr_transaction_launit
    ADD CONSTRAINT `PK__lr_trans__622533F643A3D029` PRIMARY KEY (transaction_id, launit_index);

CREATE INDEX `lr_transaction_launit__idx` ON lr_transaction_launit (transaction_id, launit_id);


-- ==========================================
-- Table: lr_transaction_metadata
-- Created: 2014-11-25 03:45:06.793000
-- Modified: 2016-09-07 09:26:48.890000
-- ==========================================

CREATE TABLE lr_transaction_metadata (
    `Id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `code` VARCHAR(64) NOT NULL,
    `label` VARCHAR(128) NOT NULL,
    `descr` VARCHAR(1000) NULL,
    `category` VARCHAR(64) NOT NULL,
    `general_term` TINYINT NULL,
    `sort_order` INT NULL,
    `hidden` TINYINT NULL,
    `group_name` VARCHAR(255) NULL,
    `workflow` VARCHAR(255) NULL,
    `group_code` VARCHAR(3) NULL,
    `normal_duration` DECIMAL(19,0) NULL,
    `lapsed_duration` DECIMAL(19,0) NULL,
    `max_duration` DECIMAL(19,0) NULL,
    `right_type` VARCHAR(64) NULL,
    `meta_type` INT NOT NULL,
    `action_type` INT NOT NULL,
    `source_party_type` VARCHAR(255) NULL,
    `target_party_type` VARCHAR(255) NULL,
    `related_transaction_code` VARCHAR(64) NULL,
    `blocking_transaction_code` VARCHAR(2000) NULL,
    `non_withdrawable_tasks` VARCHAR(500) NULL,
    `cashier_transaction_code` VARCHAR(500) NULL,
    `mandatory_docs_codes` VARCHAR(255) NULL,
    `complete_reports_codes` VARCHAR(1000) NULL,
    `reject_reports_codes` VARCHAR(1000) NULL,
    `report_templates` VARCHAR(1000) NULL,
    `detachable` TINYINT NULL,
    `related_active_rrrs` VARCHAR(500) NULL,
    `blocked_by_active_rrrs` VARCHAR(500) NULL,
    `discharge_active_rrrs` VARCHAR(500) NULL,
    `modify_active_rrrs` VARCHAR(500) NULL,
    `create_new_rrrs` VARCHAR(500) NULL,
    `retrieve_source_parties` VARCHAR(255) NULL,
    `retrieve_target_parties` VARCHAR(255) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    `stamp_duty` VARCHAR(255) NULL,
    `cashier_code_based_on_source` VARCHAR(500) NULL,
    `mandatory_scan_outgoing_document_codes` varchar(500) NULL
);

ALTER TABLE lr_transaction_metadata
    ADD CONSTRAINT `PK__lr_trans__3214EC07486BD5FA` PRIMARY KEY (Id);


-- ==========================================
-- Table: lr_transaction_note
-- Created: 2014-11-25 03:45:06.797000
-- Modified: 2014-11-25 03:45:07.283000
-- ==========================================

CREATE TABLE lr_transaction_note (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `note_type` DECIMAL(19,0) NOT NULL,
    `comments` VARCHAR(800) NULL,
    `user_name` VARCHAR(150) NULL,
    `task_id` DECIMAL(19,0) NULL,
    `task_name` VARCHAR(250) NULL,
    `comment_ref` VARCHAR(250) NULL,
    `create_date` DATETIME NULL,
    `transaction_id` DECIMAL(19,0) NULL,
    `note_index` INT NULL
);

ALTER TABLE lr_transaction_note
    ADD CONSTRAINT `PK__lr_trans__3213E83F3C36B050` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_transaction_party
-- Created: 2014-11-25 03:45:06.797000
-- Modified: 2014-11-25 03:45:27.237000
-- ==========================================

CREATE TABLE lr_transaction_party (
    `transaction_id` DECIMAL(19,0) NOT NULL,
    `party_id` DECIMAL(19,0) NOT NULL,
    `party_index` INT NOT NULL
);

ALTER TABLE lr_transaction_party
    ADD CONSTRAINT `PK__lr_trans__6437D215911BAEDB` PRIMARY KEY (transaction_id, party_index);

CREATE INDEX `lr_transaction_party__idx` ON lr_transaction_party (transaction_id, party_id);


-- ==========================================
-- Table: lr_transaction_record
-- Created: 2014-11-25 03:45:06.800000
-- Modified: 2014-11-25 03:45:27.243000
-- ==========================================

CREATE TABLE lr_transaction_record (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `operation_type` DECIMAL(19,0) NOT NULL,
    `source_rrr` DECIMAL(19,0) NULL,
    `target_rrr` DECIMAL(19,0) NULL,
    `transaction_id` DECIMAL(19,0) NULL,
    `record_index` INT NULL
);

ALTER TABLE lr_transaction_record
    ADD CONSTRAINT `PK__lr_trans__3213E83FF6B9CD01` PRIMARY KEY (id);

CREATE INDEX `lr_transaction_record_operation_type_idx` ON lr_transaction_record (operation_type);
CREATE INDEX `lr_transaction_record_transaction_id_idx` ON lr_transaction_record (transaction_id);


-- ==========================================
-- Table: lr_usage
-- Created: 2014-11-25 03:45:06.800000
-- Modified: 2014-11-25 03:45:07.290000
-- ==========================================

CREATE TABLE lr_usage (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `usage_type` DECIMAL(19,0) NOT NULL,
    `comments` VARCHAR(800) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE lr_usage
    ADD CONSTRAINT `PK__lr_usage__3213E83FB9970F7B` PRIMARY KEY (id);


-- ==========================================
-- Table: lr_valuation
-- Created: 2014-11-25 03:45:06.803000
-- Modified: 2014-11-25 03:45:07.300000
-- ==========================================

CREATE TABLE lr_valuation (
    `id` DECIMAL(19,0) NOT NULL,
    `Hjtype` VARCHAR(255) NOT NULL,
    `value` DOUBLE NULL,
    `value_type` DECIMAL(19,0) NOT NULL,
    `value_date` DATETIME NULL,
    `comments` VARCHAR(800) NULL,
    `valu1` VARCHAR(50) NULL,
    `valu2` VARCHAR(50) NULL,
    `valu_dict1` DECIMAL(19,0) NOT NULL,
    `valu_dict2` DECIMAL(19,0) NOT NULL,
    `valu_date1` DATETIME NULL,
    `valu_date2` DATETIME NULL,
    `valu_count1` INT NULL,
    `valu_count2` INT NULL,
    `suid` VARCHAR(50) NULL,
    `transaction_number` VARCHAR(50) NULL,
    `version` DECIMAL(19,0) NULL,
    `begin_lifespan_version` DATETIME NULL,
    `end_lifespan_version` DATETIME NULL
);

ALTER TABLE lr_valuation
    ADD CONSTRAINT `PK__lr_valua__3213E83F1BD1D608` PRIMARY KEY (id);


-- ==========================================
-- Table: sdms_bootstrap
-- Created: 2014-11-25 03:45:06.807000
-- Modified: 2014-11-25 03:45:06.807000
-- ==========================================

CREATE TABLE sdms_bootstrap (
    `id` BIGINT AUTO_INCREMENT NOT NULL,
    `resource_name` VARCHAR(255) NOT NULL,
    `res_version` INT NOT NULL,
    `created` DATETIME NOT NULL,
    `modified` DATETIME NOT NULL,
    `is_model` TINYINT NOT NULL,
    `resource_type` VARCHAR(255) NULL,
    PRIMARY KEY (`id`)
);

ALTER TABLE sdms_bootstrap
    ADD CONSTRAINT `PK__sdms_boo__3213E83F05EE9B6B` PRIMARY KEY (id);




SET FOREIGN_KEY_CHECKS=1;
