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

-- Total Tables: 168

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

CREATE TABLE LRSAdmin.alf_access_control_entry (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [permission_id] numeric(19,0) NOT NULL,
    [authority_id] numeric(19,0) NOT NULL,
    [allowed] tinyint NOT NULL,
    [applies] int NOT NULL,
    [context_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_access_control_entry
    ADD CONSTRAINT [PK__alf_acce__3213E83F08DA1597] PRIMARY KEY (id);

CREATE INDEX [fk_alf_ace_auth] ON LRSAdmin.alf_access_control_entry (authority_id);
CREATE INDEX [fk_alf_ace_ctx] ON LRSAdmin.alf_access_control_entry (context_id);
CREATE INDEX [fk_alf_ace_perm] ON LRSAdmin.alf_access_control_entry (permission_id);
CREATE UNIQUE INDEX [permission_id] ON LRSAdmin.alf_access_control_entry (permission_id, authority_id, allowed, applies);


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

CREATE TABLE LRSAdmin.alf_access_control_list (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [acl_id] nvarchar(36) NOT NULL,
    [latest] tinyint NOT NULL,
    [acl_version] numeric(19,0) NOT NULL,
    [inherits] tinyint NOT NULL,
    [inherits_from] numeric(19,0) NULL,
    [type] int NOT NULL,
    [inherited_acl] numeric(19,0) NULL,
    [is_versioned] tinyint NOT NULL,
    [requires_version] tinyint NOT NULL,
    [acl_change_set] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_access_control_list
    ADD CONSTRAINT [PK__alf_acce__3213E83FED23F4AC] PRIMARY KEY (id);

CREATE UNIQUE INDEX [acl_id] ON LRSAdmin.alf_access_control_list (acl_id, latest, acl_version);
CREATE INDEX [fk_alf_acl_acs] ON LRSAdmin.alf_access_control_list (acl_change_set);
CREATE INDEX [idx_alf_acl_inh] ON LRSAdmin.alf_access_control_list (inherits, inherits_from);


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

CREATE TABLE LRSAdmin.alf_ace_context (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [class_context] nvarchar(1024) NULL,
    [property_context] nvarchar(1024) NULL,
    [kvp_context] nvarchar(1024) NULL
);

ALTER TABLE LRSAdmin.alf_ace_context
    ADD CONSTRAINT [PK__alf_ace___3213E83FBAB7EA8F] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.alf_acl_change_set (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_acl_change_set
    ADD CONSTRAINT [PK__alf_acl___3213E83F82F2803F] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.alf_acl_member (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [acl_id] numeric(19,0) NOT NULL,
    [ace_id] numeric(19,0) NOT NULL,
    [pos] int NOT NULL
);

ALTER TABLE LRSAdmin.alf_acl_member
    ADD CONSTRAINT [PK__alf_acl___3213E83F98115AF8] PRIMARY KEY (id);

CREATE UNIQUE INDEX [aclm_acl_id] ON LRSAdmin.alf_acl_member (acl_id, ace_id, pos);
CREATE INDEX [fk_alf_aclm_ace] ON LRSAdmin.alf_acl_member (ace_id);
CREATE INDEX [fk_alf_aclm_acl] ON LRSAdmin.alf_acl_member (acl_id);


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

CREATE TABLE LRSAdmin.alf_activity_feed (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [post_id] numeric(19,0) NULL,
    [post_date] datetime NOT NULL,
    [activity_summary] nvarchar(1024) NULL,
    [feed_user_id] nvarchar(255) NULL,
    [activity_type] nvarchar(255) NOT NULL,
    [activity_format] nvarchar(10) NULL,
    [site_network] nvarchar(255) NULL,
    [app_tool] nvarchar(36) NULL,
    [post_user_id] nvarchar(255) NOT NULL,
    [feed_date] datetime NOT NULL
);

ALTER TABLE LRSAdmin.alf_activity_feed
    ADD CONSTRAINT [PK__alf_acti__3213E83FF6E40892] PRIMARY KEY (id);

CREATE INDEX [feed_activityformat_idx] ON LRSAdmin.alf_activity_feed (activity_format);
CREATE INDEX [feed_feeduserid_idx] ON LRSAdmin.alf_activity_feed (feed_user_id);
CREATE INDEX [feed_postdate_idx] ON LRSAdmin.alf_activity_feed (post_date);
CREATE INDEX [feed_postuserid_idx] ON LRSAdmin.alf_activity_feed (post_user_id);
CREATE INDEX [feed_sitenetwork_idx] ON LRSAdmin.alf_activity_feed (site_network);


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

CREATE TABLE LRSAdmin.alf_activity_feed_control (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [feed_user_id] nvarchar(255) NOT NULL,
    [site_network] nvarchar(255) NULL,
    [app_tool] nvarchar(36) NULL,
    [last_modified] datetime NOT NULL
);

ALTER TABLE LRSAdmin.alf_activity_feed_control
    ADD CONSTRAINT [PK__alf_acti__3213E83FA6D2E120] PRIMARY KEY (id);

CREATE INDEX [feedctrl_feeduserid_idx] ON LRSAdmin.alf_activity_feed_control (feed_user_id);


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

CREATE TABLE LRSAdmin.alf_activity_post (
    [sequence_id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [post_date] datetime NOT NULL,
    [status] nvarchar(10) NOT NULL,
    [activity_data] nvarchar(1024) NOT NULL,
    [post_user_id] nvarchar(255) NOT NULL,
    [job_task_node] int NOT NULL,
    [site_network] nvarchar(255) NULL,
    [app_tool] nvarchar(36) NULL,
    [activity_type] nvarchar(255) NOT NULL,
    [last_modified] datetime NOT NULL
);

ALTER TABLE LRSAdmin.alf_activity_post
    ADD CONSTRAINT [PK__alf_acti__B2649B241E8E74C3] PRIMARY KEY (sequence_id);

CREATE INDEX [post_jobtasknode_idx] ON LRSAdmin.alf_activity_post (job_task_node);
CREATE INDEX [post_status_idx] ON LRSAdmin.alf_activity_post (status);


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

CREATE TABLE LRSAdmin.alf_applied_patch (
    [id] nvarchar(64) NOT NULL,
    [description] nvarchar(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] nvarchar(64) NULL,
    [was_executed] tinyint NULL,
    [succeeded] tinyint NULL,
    [report] nvarchar(1024) NULL
);

ALTER TABLE LRSAdmin.alf_applied_patch
    ADD CONSTRAINT [PK__alf_appl__3213E83FA8BC8E29] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.alf_attributes (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [type] nvarchar(1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [acl_id] numeric(19,0) NULL,
    [bool_value] tinyint NULL,
    [byte_value] tinyint NULL,
    [short_value] int NULL,
    [int_value] int NULL,
    [long_value] numeric(19,0) NULL,
    [float_value] float NULL,
    [double_value] float NULL,
    [string_value] nvarchar(1024) NULL,
    [serializable_value] image NULL
);

ALTER TABLE LRSAdmin.alf_attributes
    ADD CONSTRAINT [PK__alf_attr__3213E83F855C2DDB] PRIMARY KEY (id);

CREATE INDEX [fk_alf_attr_acl] ON LRSAdmin.alf_attributes (acl_id);


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

CREATE TABLE LRSAdmin.alf_audit_app (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] int NOT NULL,
    [app_name_id] numeric(19,0) NOT NULL,
    [audit_model_id] numeric(19,0) NOT NULL,
    [disabled_paths_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_audit_app
    ADD CONSTRAINT [PK__alf_audi__3213E83F623F030A] PRIMARY KEY (id);

CREATE INDEX [fk_alf_aud_app_dis] ON LRSAdmin.alf_audit_app (disabled_paths_id);
CREATE INDEX [fk_alf_aud_app_mod] ON LRSAdmin.alf_audit_app (audit_model_id);
CREATE UNIQUE INDEX [idx_alf_aud_app_an] ON LRSAdmin.alf_audit_app (app_name_id);


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

CREATE TABLE LRSAdmin.alf_audit_entry (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [audit_app_id] numeric(19,0) NOT NULL,
    [audit_time] numeric(19,0) NOT NULL,
    [audit_user_id] numeric(19,0) NULL,
    [audit_values_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_audit_entry
    ADD CONSTRAINT [PK__alf_audi__3213E83FD3710B6C] PRIMARY KEY (id);

CREATE INDEX [fk_alf_aud_ent_app] ON LRSAdmin.alf_audit_entry (audit_app_id);
CREATE INDEX [fk_alf_aud_ent_pro] ON LRSAdmin.alf_audit_entry (audit_values_id);
CREATE INDEX [fk_alf_aud_ent_use] ON LRSAdmin.alf_audit_entry (audit_user_id);
CREATE INDEX [idx_alf_aud_ent_tm] ON LRSAdmin.alf_audit_entry (audit_time);


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

CREATE TABLE LRSAdmin.alf_audit_model (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [content_data_id] numeric(19,0) NOT NULL,
    [content_crc] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_audit_model
    ADD CONSTRAINT [PK__alf_audi__3213E83FD96C2CDA] PRIMARY KEY (id);

CREATE INDEX [fk_alf_aud_mod_cd] ON LRSAdmin.alf_audit_model (content_data_id);
CREATE UNIQUE INDEX [idx_alf_aud_mod_cr] ON LRSAdmin.alf_audit_model (content_crc);


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

CREATE TABLE LRSAdmin.alf_authority (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [authority] nvarchar(100) NULL,
    [crc] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_authority
    ADD CONSTRAINT [PK__alf_auth__3213E83FE9CE2594] PRIMARY KEY (id);

CREATE UNIQUE INDEX [authority] ON LRSAdmin.alf_authority (authority, crc);
CREATE INDEX [idx_alf_auth_aut] ON LRSAdmin.alf_authority (authority);


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

CREATE TABLE LRSAdmin.alf_authority_alias (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [auth_id] numeric(19,0) NOT NULL,
    [alias_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_authority_alias
    ADD CONSTRAINT [PK__alf_auth__3213E83FD608AA04] PRIMARY KEY (id);

CREATE UNIQUE INDEX [auth_id] ON LRSAdmin.alf_authority_alias (auth_id, alias_id);
CREATE INDEX [fk_alf_autha_ali] ON LRSAdmin.alf_authority_alias (alias_id);
CREATE INDEX [fk_alf_autha_aut] ON LRSAdmin.alf_authority_alias (auth_id);


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

CREATE TABLE LRSAdmin.alf_child_assoc (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [parent_node_id] numeric(19,0) NOT NULL,
    [type_qname_id] numeric(19,0) NOT NULL,
    [child_node_name_crc] numeric(19,0) NOT NULL,
    [child_node_name] nvarchar(50) NOT NULL,
    [child_node_id] numeric(19,0) NOT NULL,
    [qname_ns_id] numeric(19,0) NOT NULL,
    [qname_localname] nvarchar(255) NOT NULL,
    [qname_crc] numeric(19,0) NOT NULL,
    [is_primary] tinyint NULL,
    [assoc_index] int NULL
);

ALTER TABLE LRSAdmin.alf_child_assoc
    ADD CONSTRAINT [PK__alf_chil__3213E83FB05F6BCB] PRIMARY KEY (id);

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


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

CREATE TABLE LRSAdmin.alf_content_data (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [content_url_id] numeric(19,0) NULL,
    [content_mimetype_id] numeric(19,0) NULL,
    [content_encoding_id] numeric(19,0) NULL,
    [content_locale_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_content_data
    ADD CONSTRAINT [PK__alf_cont__3213E83F1CE9F61D] PRIMARY KEY (id);

CREATE INDEX [CONTENT_URL_REF_IDX] ON LRSAdmin.alf_content_data (content_url_id);
CREATE INDEX [fk_alf_cont_enc] ON LRSAdmin.alf_content_data (content_encoding_id);
CREATE INDEX [fk_alf_cont_loc] ON LRSAdmin.alf_content_data (content_locale_id);
CREATE INDEX [fk_alf_cont_mim] ON LRSAdmin.alf_content_data (content_mimetype_id);
CREATE INDEX [fk_alf_cont_url] ON LRSAdmin.alf_content_data (content_url_id);


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

CREATE TABLE LRSAdmin.alf_content_url (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [content_url] nvarchar(255) NOT NULL,
    [content_url_short] nvarchar(12) NOT NULL,
    [content_url_crc] numeric(19,0) NOT NULL,
    [content_size] numeric(19,0) NOT NULL,
    [orphan_time] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_content_url
    ADD CONSTRAINT [PK__alf_cont__3213E83FA9486923] PRIMARY KEY (id);

CREATE UNIQUE INDEX [idx_alf_conturl_cr] ON LRSAdmin.alf_content_url (content_url_short, content_url_crc);
CREATE INDEX [idx_alf_conturl_ot] ON LRSAdmin.alf_content_url (orphan_time);


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

CREATE TABLE LRSAdmin.alf_encoding (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [encoding_str] nvarchar(100) NOT NULL
);

ALTER TABLE LRSAdmin.alf_encoding
    ADD CONSTRAINT [PK__alf_enco__3213E83F23A8246D] PRIMARY KEY (id);

CREATE UNIQUE INDEX [UQ__alf_enco__9335B4D344E1CCC7] ON LRSAdmin.alf_encoding (encoding_str);


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

CREATE TABLE LRSAdmin.alf_global_attributes (
    [name] nvarchar(160) NOT NULL,
    [attribute] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_global_attributes
    ADD CONSTRAINT [PK__alf_glob__72E12F1AD6CE43E7] PRIMARY KEY (name);

CREATE UNIQUE INDEX [attribute] ON LRSAdmin.alf_global_attributes (attribute);
CREATE INDEX [fk_alf_gatt_att] ON LRSAdmin.alf_global_attributes (attribute);


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

CREATE TABLE LRSAdmin.alf_list_attribute_entries (
    [list_id] numeric(19,0) NOT NULL,
    [mindex] int NOT NULL,
    [attribute_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_list_attribute_entries
    ADD CONSTRAINT [PK__alf_list__0D0F4F069EFCE958] PRIMARY KEY (list_id, mindex);

CREATE INDEX [fk_alf_lent_att] ON LRSAdmin.alf_list_attribute_entries (attribute_id);
CREATE INDEX [fk_alf_lent_latt] ON LRSAdmin.alf_list_attribute_entries (list_id);


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

CREATE TABLE LRSAdmin.alf_locale (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [locale_str] nvarchar(20) NOT NULL
);

ALTER TABLE LRSAdmin.alf_locale
    ADD CONSTRAINT [PK__alf_loca__3213E83F3D21314B] PRIMARY KEY (id);

CREATE UNIQUE INDEX [locale_str] ON LRSAdmin.alf_locale (locale_str);


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

CREATE TABLE LRSAdmin.alf_lock (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [shared_resource_id] numeric(19,0) NOT NULL,
    [excl_resource_id] numeric(19,0) NOT NULL,
    [lock_token] nvarchar(36) NOT NULL,
    [start_time] numeric(19,0) NOT NULL,
    [expiry_time] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_lock
    ADD CONSTRAINT [PK__alf_lock__3213E83FBEC06345] PRIMARY KEY (id);

CREATE INDEX [fk_alf_lock_excl] ON LRSAdmin.alf_lock (excl_resource_id);
CREATE UNIQUE INDEX [idx_alf_lock_key] ON LRSAdmin.alf_lock (shared_resource_id, excl_resource_id);


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

CREATE TABLE LRSAdmin.alf_lock_resource (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [qname_ns_id] numeric(19,0) NOT NULL,
    [qname_localname] nvarchar(255) NOT NULL
);

ALTER TABLE LRSAdmin.alf_lock_resource
    ADD CONSTRAINT [PK__alf_lock__3213E83F26D42CDF] PRIMARY KEY (id);

CREATE UNIQUE INDEX [idx_alf_lockr_key] ON LRSAdmin.alf_lock_resource (qname_ns_id, qname_localname);


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

CREATE TABLE LRSAdmin.alf_map_attribute_entries (
    [map_id] numeric(19,0) NOT NULL,
    [mkey] nvarchar(160) NOT NULL,
    [attribute_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_map_attribute_entries
    ADD CONSTRAINT [PK__alf_map___E57C53D1AA8E062C] PRIMARY KEY (map_id, mkey);

CREATE INDEX [fk_alf_matt_att] ON LRSAdmin.alf_map_attribute_entries (attribute_id);
CREATE INDEX [fk_alf_matt_matt] ON LRSAdmin.alf_map_attribute_entries (map_id);


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

CREATE TABLE LRSAdmin.alf_mimetype (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [mimetype_str] nvarchar(100) NOT NULL
);

ALTER TABLE LRSAdmin.alf_mimetype
    ADD CONSTRAINT [PK__alf_mime__3213E83F88777436] PRIMARY KEY (id);

CREATE UNIQUE INDEX [UQ__alf_mime__25B6CB677F2DBB6B] ON LRSAdmin.alf_mimetype (mimetype_str);


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

CREATE TABLE LRSAdmin.alf_namespace (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [uri] nvarchar(100) NOT NULL
);

ALTER TABLE LRSAdmin.alf_namespace
    ADD CONSTRAINT [PK__alf_name__3213E83FD86F49BC] PRIMARY KEY (id);

CREATE UNIQUE INDEX [uri] ON LRSAdmin.alf_namespace (uri);


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

CREATE TABLE LRSAdmin.alf_node (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [store_id] numeric(19,0) NOT NULL,
    [uuid] nvarchar(36) NOT NULL,
    [transaction_id] numeric(19,0) NOT NULL,
    [node_deleted] tinyint NOT NULL,
    [type_qname_id] numeric(19,0) NOT NULL,
    [acl_id] numeric(19,0) NULL,
    [audit_creator] nvarchar(255) NULL,
    [audit_created] nvarchar(30) NULL,
    [audit_modifier] nvarchar(255) NULL,
    [audit_modified] nvarchar(30) NULL,
    [audit_accessed] nvarchar(30) NULL
);

ALTER TABLE LRSAdmin.alf_node
    ADD CONSTRAINT [PK__alf_node__3213E83F0F1E6181] PRIMARY KEY (id);

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


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

CREATE TABLE LRSAdmin.alf_node_aspects (
    [node_id] numeric(19,0) NOT NULL,
    [qname_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_node_aspects
    ADD CONSTRAINT [PK__alf_node__76933324E7F540A5] PRIMARY KEY (node_id, qname_id);

CREATE INDEX [fk_alf_nasp_n] ON LRSAdmin.alf_node_aspects (node_id);
CREATE INDEX [fk_alf_nasp_qn] ON LRSAdmin.alf_node_aspects (qname_id);


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

CREATE TABLE LRSAdmin.alf_node_assoc (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [source_node_id] numeric(19,0) NOT NULL,
    [target_node_id] numeric(19,0) NOT NULL,
    [type_qname_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_node_assoc
    ADD CONSTRAINT [PK__alf_node__3213E83FC10EFF63] PRIMARY KEY (id);

CREATE INDEX [fk_alf_nass_snode] ON LRSAdmin.alf_node_assoc (source_node_id);
CREATE INDEX [fk_alf_nass_tnode] ON LRSAdmin.alf_node_assoc (target_node_id);
CREATE INDEX [fk_alf_nass_tqn] ON LRSAdmin.alf_node_assoc (type_qname_id);
CREATE UNIQUE INDEX [source_node_id] ON LRSAdmin.alf_node_assoc (source_node_id, target_node_id, type_qname_id);


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

CREATE TABLE LRSAdmin.alf_node_properties (
    [node_id] numeric(19,0) NOT NULL,
    [actual_type_n] int NOT NULL,
    [persisted_type_n] int NOT NULL,
    [boolean_value] tinyint NULL,
    [long_value] numeric(19,0) NULL,
    [float_value] float NULL,
    [double_value] float NULL,
    [string_value] nvarchar(1024) NULL,
    [serializable_value] image NULL,
    [qname_id] numeric(19,0) NOT NULL,
    [list_index] int NOT NULL,
    [locale_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.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 LRSAdmin.alf_node_properties (actual_type_n, persisted_type_n);
CREATE INDEX [fk_alf_nprop_loc] ON LRSAdmin.alf_node_properties (locale_id);
CREATE INDEX [fk_alf_nprop_n] ON LRSAdmin.alf_node_properties (node_id);
CREATE INDEX [fk_alf_nprop_qn] ON LRSAdmin.alf_node_properties (qname_id);


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

CREATE TABLE LRSAdmin.alf_permission (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [type_qname_id] numeric(19,0) NOT NULL,
    [name] nvarchar(100) NOT NULL
);

ALTER TABLE LRSAdmin.alf_permission
    ADD CONSTRAINT [PK__alf_perm__3213E83FE32FDFF1] PRIMARY KEY (id);

CREATE INDEX [fk_alf_perm_tqn] ON LRSAdmin.alf_permission (type_qname_id);
CREATE UNIQUE INDEX [type_qname_id] ON LRSAdmin.alf_permission (type_qname_id, name);


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

CREATE TABLE LRSAdmin.alf_prop_class (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [java_class_name] nvarchar(255) NOT NULL,
    [java_class_name_short] nvarchar(32) NOT NULL,
    [java_class_name_crc] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_prop_class
    ADD CONSTRAINT [PK__alf_prop__3213E83F69C859BB] PRIMARY KEY (id);

CREATE INDEX [idx_alf_propc_clas] ON LRSAdmin.alf_prop_class (java_class_name);
CREATE UNIQUE INDEX [idx_alf_propc_crc] ON LRSAdmin.alf_prop_class (java_class_name_crc, java_class_name_short);


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

CREATE TABLE LRSAdmin.alf_prop_date_value (
    [date_value] numeric(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 LRSAdmin.alf_prop_date_value
    ADD CONSTRAINT [PK__alf_prop__92DCEC6950DD433E] PRIMARY KEY (date_value);

CREATE INDEX [idx_alf_propdt_dt] ON LRSAdmin.alf_prop_date_value (full_year, month_of_year, day_of_month);


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

CREATE TABLE LRSAdmin.alf_prop_double_value (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [double_value] float NOT NULL
);

ALTER TABLE LRSAdmin.alf_prop_double_value
    ADD CONSTRAINT [PK__alf_prop__3213E83F407FA1E7] PRIMARY KEY (id);

CREATE UNIQUE INDEX [idx_alf_propd_val] ON LRSAdmin.alf_prop_double_value (double_value);


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

CREATE TABLE LRSAdmin.alf_prop_link (
    [root_prop_id] numeric(19,0) NOT NULL,
    [prop_index] numeric(19,0) NOT NULL,
    [contained_in] numeric(19,0) NOT NULL,
    [key_prop_id] numeric(19,0) NOT NULL,
    [value_prop_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.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 LRSAdmin.alf_prop_link (key_prop_id);
CREATE INDEX [fk_alf_propln_val] ON LRSAdmin.alf_prop_link (value_prop_id);
CREATE INDEX [idx_alf_propln_for] ON LRSAdmin.alf_prop_link (root_prop_id, key_prop_id, value_prop_id);


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

CREATE TABLE LRSAdmin.alf_prop_root (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] int NOT NULL
);

ALTER TABLE LRSAdmin.alf_prop_root
    ADD CONSTRAINT [PK__alf_prop__3213E83F6B444F9C] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.alf_prop_serializable_value (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [serializable_value] image NOT NULL
);

ALTER TABLE LRSAdmin.alf_prop_serializable_value
    ADD CONSTRAINT [PK__alf_prop__3213E83F757CEBE9] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.alf_prop_string_value (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [string_value] nvarchar(1024) NOT NULL,
    [string_end_lower] nvarchar(16) NOT NULL,
    [string_crc] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_prop_string_value
    ADD CONSTRAINT [PK__alf_prop__3213E83F06006586] PRIMARY KEY (id);

CREATE UNIQUE INDEX [idx_alf_props_crc] ON LRSAdmin.alf_prop_string_value (string_end_lower, string_crc);


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

CREATE TABLE LRSAdmin.alf_prop_unique_ctx (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] int NOT NULL,
    [value1_prop_id] numeric(19,0) NOT NULL,
    [value2_prop_id] numeric(19,0) NOT NULL,
    [value3_prop_id] numeric(19,0) NOT NULL,
    [prop1_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_prop_unique_ctx
    ADD CONSTRAINT [PK__alf_prop__3213E83F9A00E3B3] PRIMARY KEY (id);

CREATE INDEX [fk_alf_propuctx_p1] ON LRSAdmin.alf_prop_unique_ctx (prop1_id);
CREATE INDEX [fk_alf_propuctx_v2] ON LRSAdmin.alf_prop_unique_ctx (value2_prop_id);
CREATE INDEX [fk_alf_propuctx_v3] ON LRSAdmin.alf_prop_unique_ctx (value3_prop_id);
CREATE UNIQUE INDEX [idx_alf_propuctx] ON LRSAdmin.alf_prop_unique_ctx (value1_prop_id, value2_prop_id, value3_prop_id);


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

CREATE TABLE LRSAdmin.alf_prop_value (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [actual_type_id] numeric(19,0) NOT NULL,
    [persisted_type] tinyint NOT NULL,
    [long_value] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_prop_value
    ADD CONSTRAINT [PK__alf_prop__3213E83F7087DBC9] PRIMARY KEY (id);

CREATE UNIQUE INDEX [idx_alf_propv_act] ON LRSAdmin.alf_prop_value (actual_type_id, long_value);
CREATE INDEX [idx_alf_propv_per] ON LRSAdmin.alf_prop_value (persisted_type, long_value);


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

CREATE TABLE LRSAdmin.alf_qname (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [ns_id] numeric(19,0) NOT NULL,
    [local_name] nvarchar(200) NOT NULL
);

ALTER TABLE LRSAdmin.alf_qname
    ADD CONSTRAINT [PK__alf_qnam__3213E83FC31D650E] PRIMARY KEY (id);

CREATE INDEX [fk_alf_qname_ns] ON LRSAdmin.alf_qname (ns_id);
CREATE UNIQUE INDEX [ns_id] ON LRSAdmin.alf_qname (ns_id, local_name);


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

CREATE TABLE LRSAdmin.alf_server (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [ip_address] nvarchar(39) NOT NULL
);

ALTER TABLE LRSAdmin.alf_server
    ADD CONSTRAINT [PK__alf_serv__3213E83FD64576BA] PRIMARY KEY (id);

CREATE UNIQUE INDEX [ip_address] ON LRSAdmin.alf_server (ip_address);


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

CREATE TABLE LRSAdmin.alf_store (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [protocol] nvarchar(50) NOT NULL,
    [identifier] nvarchar(100) NOT NULL,
    [root_node_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_store
    ADD CONSTRAINT [PK__alf_stor__3213E83FD0E1276D] PRIMARY KEY (id);

CREATE INDEX [fk_alf_store_root] ON LRSAdmin.alf_store (root_node_id);
CREATE UNIQUE INDEX [protocol] ON LRSAdmin.alf_store (protocol, identifier);


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

CREATE TABLE LRSAdmin.alf_transaction (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [server_id] numeric(19,0) NULL,
    [change_txn_id] nvarchar(56) NOT NULL,
    [commit_time_ms] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.alf_transaction
    ADD CONSTRAINT [PK__alf_tran__3213E83F36DBC5E2] PRIMARY KEY (id);

CREATE INDEX [COMMIT_TIME_MS_ID_SID_IDX] ON LRSAdmin.alf_transaction (commit_time_ms, id, server_id);
CREATE INDEX [fk_alf_txn_svr] ON LRSAdmin.alf_transaction (server_id);
CREATE INDEX [idx_alf_txn_ctms] ON LRSAdmin.alf_transaction (commit_time_ms);


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

CREATE TABLE LRSAdmin.alf_usage_delta (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version] numeric(19,0) NOT NULL,
    [node_id] numeric(19,0) NOT NULL,
    [delta_size] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.alf_usage_delta
    ADD CONSTRAINT [PK__alf_usag__3213E83F0F7D0AC7] PRIMARY KEY (id);

CREATE INDEX [fk_alf_usaged_n] ON LRSAdmin.alf_usage_delta (node_id);


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

CREATE TABLE LRSAdmin.avm_aspects (
    [node_id] numeric(19,0) NOT NULL,
    [qname_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.avm_aspects
    ADD CONSTRAINT [PK__avm_aspe__769333247137DC92] PRIMARY KEY (node_id, qname_id);

CREATE INDEX [fk_avm_nasp_n] ON LRSAdmin.avm_aspects (node_id);
CREATE INDEX [fk_avm_nasp_qn] ON LRSAdmin.avm_aspects (qname_id);


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

CREATE TABLE LRSAdmin.avm_child_entries (
    [parent_id] numeric(19,0) NOT NULL,
    [lc_name] nvarchar(160) NOT NULL,
    [name] nvarchar(160) NOT NULL,
    [child_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.avm_child_entries
    ADD CONSTRAINT [PK__avm_chil__AB6CCF08E0E13C4D] PRIMARY KEY (parent_id, lc_name);

CREATE INDEX [fk_avm_ce_child] ON LRSAdmin.avm_child_entries (child_id);
CREATE INDEX [fk_avm_ce_parent] ON LRSAdmin.avm_child_entries (parent_id);
CREATE INDEX [idx_avm_ce_lc_name] ON LRSAdmin.avm_child_entries (lc_name, parent_id);


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

CREATE TABLE LRSAdmin.avm_history_links (
    [ancestor] numeric(19,0) NOT NULL,
    [descendent] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.avm_history_links
    ADD CONSTRAINT [PK__avm_hist__E3725EF9F8F8B10E] PRIMARY KEY (ancestor, descendent);

CREATE INDEX [fk_avm_hl_ancestor] ON LRSAdmin.avm_history_links (ancestor);
CREATE INDEX [fk_avm_hl_desc] ON LRSAdmin.avm_history_links (descendent);
CREATE INDEX [idx_avm_hl_revpk] ON LRSAdmin.avm_history_links (descendent, ancestor);


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

CREATE TABLE LRSAdmin.avm_merge_links (
    [mfrom] numeric(19,0) NOT NULL,
    [mto] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.avm_merge_links
    ADD CONSTRAINT [PK__avm_merg__24FA01F2A17A4EA8] PRIMARY KEY (mfrom, mto);

CREATE INDEX [fk_avm_ml_from] ON LRSAdmin.avm_merge_links (mfrom);
CREATE INDEX [fk_avm_ml_to] ON LRSAdmin.avm_merge_links (mto);


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

CREATE TABLE LRSAdmin.avm_node_properties (
    [node_id] numeric(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] numeric(19,0) NULL,
    [float_value] float NULL,
    [double_value] float NULL,
    [string_value] nvarchar(1024) NULL,
    [serializable_value] image NULL,
    [qname_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.avm_node_properties
    ADD CONSTRAINT [PK__avm_node__769333241A7F57CA] PRIMARY KEY (node_id, qname_id);

CREATE INDEX [fk_avm_nprop_n] ON LRSAdmin.avm_node_properties (node_id);
CREATE INDEX [fk_avm_nprop_qn] ON LRSAdmin.avm_node_properties (qname_id);


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

CREATE TABLE LRSAdmin.avm_nodes (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [class_type] nvarchar(20) NOT NULL,
    [vers] numeric(19,0) NOT NULL,
    [version_id] int NOT NULL,
    [guid] nvarchar(36) NULL,
    [creator] nvarchar(255) NOT NULL,
    [owner] nvarchar(255) NOT NULL,
    [lastModifier] nvarchar(255) NOT NULL,
    [createDate] numeric(19,0) NOT NULL,
    [modDate] numeric(19,0) NOT NULL,
    [accessDate] numeric(19,0) NOT NULL,
    [is_root] tinyint NULL,
    [store_new_id] numeric(19,0) NULL,
    [acl_id] numeric(19,0) NULL,
    [deletedType] int NULL,
    [layer_id] numeric(19,0) NULL,
    [indirection] nvarchar(1024) NULL,
    [indirection_version] int NULL,
    [primary_indirection] tinyint NULL,
    [opacity] tinyint NULL,
    [content_url] nvarchar(128) NULL,
    [mime_type] nvarchar(100) NULL,
    [encoding] nvarchar(16) NULL,
    [length] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.avm_nodes
    ADD CONSTRAINT [PK__avm_node__3213E83F499BA436] PRIMARY KEY (id);

CREATE INDEX [fk_avm_n_acl] ON LRSAdmin.avm_nodes (acl_id);
CREATE INDEX [fk_avm_n_store] ON LRSAdmin.avm_nodes (store_new_id);
CREATE INDEX [idx_avm_n_pi] ON LRSAdmin.avm_nodes (primary_indirection);


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

CREATE TABLE LRSAdmin.avm_store_properties (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [avm_store_id] numeric(19,0) NULL,
    [qname_id] numeric(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] numeric(19,0) NULL,
    [float_value] float NULL,
    [double_value] float NULL,
    [string_value] nvarchar(1024) NULL,
    [serializable_value] image NULL
);

ALTER TABLE LRSAdmin.avm_store_properties
    ADD CONSTRAINT [PK__avm_stor__3213E83F7745AD8B] PRIMARY KEY (id);

CREATE INDEX [fk_avm_sprop_qname] ON LRSAdmin.avm_store_properties (qname_id);
CREATE INDEX [fk_avm_sprop_store] ON LRSAdmin.avm_store_properties (avm_store_id);


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

CREATE TABLE LRSAdmin.avm_stores (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [vers] numeric(19,0) NOT NULL,
    [name] nvarchar(255) NULL,
    [next_version_id] int NOT NULL,
    [current_root_id] numeric(19,0) NULL,
    [acl_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.avm_stores
    ADD CONSTRAINT [PK__avm_stor__3213E83FB7C43518] PRIMARY KEY (id);

CREATE INDEX [fk_avm_s_acl] ON LRSAdmin.avm_stores (acl_id);
CREATE INDEX [fk_avm_s_root] ON LRSAdmin.avm_stores (current_root_id);
CREATE UNIQUE INDEX [UQ__avm_stor__72E12F1B7EF5E282] ON LRSAdmin.avm_stores (name);


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

CREATE TABLE LRSAdmin.avm_version_layered_node_entry (
    [version_root_id] numeric(19,0) NOT NULL,
    [md5sum] nvarchar(32) NOT NULL,
    [path] nvarchar(1024) NULL
);

ALTER TABLE LRSAdmin.avm_version_layered_node_entry
    ADD CONSTRAINT [PK__avm_vers__F3ED4C9457342DC5] PRIMARY KEY (version_root_id, md5sum);

CREATE INDEX [fk_avm_vlne_vr] ON LRSAdmin.avm_version_layered_node_entry (version_root_id);


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

CREATE TABLE LRSAdmin.avm_version_roots (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [version_id] int NOT NULL,
    [avm_store_id] numeric(19,0) NOT NULL,
    [create_date] numeric(19,0) NOT NULL,
    [creator] nvarchar(255) NOT NULL,
    [root_id] numeric(19,0) NOT NULL,
    [tag] nvarchar(255) NULL,
    [description] nvarchar(1024) NULL
);

ALTER TABLE LRSAdmin.avm_version_roots
    ADD CONSTRAINT [PK__avm_vers__3213E83F3AA1DEC2] PRIMARY KEY (id);

CREATE INDEX [fk_avm_vr_root] ON LRSAdmin.avm_version_roots (root_id);
CREATE INDEX [fk_avm_vr_store] ON LRSAdmin.avm_version_roots (avm_store_id);
CREATE INDEX [idx_avm_vr_revuq] ON LRSAdmin.avm_version_roots (avm_store_id, version_id);
CREATE INDEX [idx_avm_vr_version] ON LRSAdmin.avm_version_roots (version_id);
CREATE UNIQUE INDEX [UQ__avm_vers__EF2A660E853BEB3E] ON LRSAdmin.avm_version_roots (version_id, avm_store_id);


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

CREATE TABLE LRSAdmin.JBPM_ACTION (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [class] char(1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [ISPROPAGATIONALLOWED_] tinyint NULL,
    [ACTIONEXPRESSION_] nvarchar(255) NULL,
    [ISASYNC_] tinyint NULL,
    [REFERENCEDACTION_] numeric(19,0) NULL,
    [ACTIONDELEGATION_] numeric(19,0) NULL,
    [EVENT_] numeric(19,0) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [TIMERNAME_] nvarchar(255) NULL,
    [DUEDATE_] nvarchar(255) NULL,
    [REPEAT_] nvarchar(255) NULL,
    [TRANSITIONNAME_] nvarchar(255) NULL,
    [TIMERACTION_] numeric(19,0) NULL,
    [EXPRESSION_] nvarchar(MAX) NULL,
    [EVENTINDEX_] int NULL,
    [EXCEPTIONHANDLER_] numeric(19,0) NULL,
    [EXCEPTIONHANDLERINDEX_] int NULL
);

ALTER TABLE LRSAdmin.JBPM_ACTION
    ADD CONSTRAINT [PK__JBPM_ACT__C4971C0FD53A8A2C] PRIMARY KEY (ID_);

CREATE INDEX [FK_ACTION_ACTNDEL] ON LRSAdmin.JBPM_ACTION (ACTIONDELEGATION_);
CREATE INDEX [FK_ACTION_EVENT] ON LRSAdmin.JBPM_ACTION (EVENT_);
CREATE INDEX [FK_ACTION_EXPTHDL] ON LRSAdmin.JBPM_ACTION (EXCEPTIONHANDLER_);
CREATE INDEX [FK_ACTION_PROCDEF] ON LRSAdmin.JBPM_ACTION (PROCESSDEFINITION_);
CREATE INDEX [FK_ACTION_REFACT] ON LRSAdmin.JBPM_ACTION (REFERENCEDACTION_);
CREATE INDEX [FK_CRTETIMERACT_TA] ON LRSAdmin.JBPM_ACTION (TIMERACTION_);


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

CREATE TABLE LRSAdmin.JBPM_BYTEARRAY (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [FILEDEFINITION_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_BYTEARRAY
    ADD CONSTRAINT [PK__JBPM_BYT__C4971C0FD3B340EE] PRIMARY KEY (ID_);

CREATE INDEX [FK_BYTEARR_FILDEF] ON LRSAdmin.JBPM_BYTEARRAY (FILEDEFINITION_);


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

CREATE TABLE LRSAdmin.JBPM_BYTEBLOCK (
    [PROCESSFILE_] numeric(19,0) NOT NULL,
    [BYTES_] varbinary NULL,
    [INDEX_] int NOT NULL
);

ALTER TABLE LRSAdmin.JBPM_BYTEBLOCK
    ADD CONSTRAINT [PK__JBPM_BYT__84996C4EBEF9524E] PRIMARY KEY (PROCESSFILE_, INDEX_);

CREATE INDEX [FK_BYTEBLOCK_FILE] ON LRSAdmin.JBPM_BYTEBLOCK (PROCESSFILE_);


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

CREATE TABLE LRSAdmin.JBPM_COMMENT (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [ACTORID_] nvarchar(255) NULL,
    [TIME_] datetime NULL,
    [MESSAGE_] nvarchar(MAX) NULL,
    [TOKEN_] numeric(19,0) NULL,
    [TASKINSTANCE_] numeric(19,0) NULL,
    [TOKENINDEX_] int NULL,
    [TASKINSTANCEINDEX_] int NULL
);

ALTER TABLE LRSAdmin.JBPM_COMMENT
    ADD CONSTRAINT [PK__JBPM_COM__C4971C0F98B5F30D] PRIMARY KEY (ID_);

CREATE INDEX [FK_COMMENT_TOKEN] ON LRSAdmin.JBPM_COMMENT (TOKEN_);
CREATE INDEX [FK_COMMENT_TSK] ON LRSAdmin.JBPM_COMMENT (TASKINSTANCE_);


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

CREATE TABLE LRSAdmin.JBPM_DECISIONCONDITIONS (
    [DECISION_] numeric(19,0) NOT NULL,
    [TRANSITIONNAME_] nvarchar(255) NULL,
    [EXPRESSION_] nvarchar(255) NULL,
    [INDEX_] int NOT NULL
);

ALTER TABLE LRSAdmin.JBPM_DECISIONCONDITIONS
    ADD CONSTRAINT [PK__JBPM_DEC__AAF025B0570710F3] PRIMARY KEY (DECISION_, INDEX_);

CREATE INDEX [FK_DECCOND_DEC] ON LRSAdmin.JBPM_DECISIONCONDITIONS (DECISION_);


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

CREATE TABLE LRSAdmin.JBPM_DELEGATION (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASSNAME_] nvarchar(MAX) NULL,
    [CONFIGURATION_] nvarchar(MAX) NULL,
    [CONFIGTYPE_] nvarchar(255) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_DELEGATION
    ADD CONSTRAINT [PK__JBPM_DEL__C4971C0FF9B9AA3A] PRIMARY KEY (ID_);

CREATE INDEX [FK_DELEGATION_PRCD] ON LRSAdmin.JBPM_DELEGATION (PROCESSDEFINITION_);


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

CREATE TABLE LRSAdmin.JBPM_EVENT (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [EVENTTYPE_] nvarchar(255) NULL,
    [TYPE_] char(1) NULL,
    [GRAPHELEMENT_] numeric(19,0) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [NODE_] numeric(19,0) NULL,
    [TRANSITION_] numeric(19,0) NULL,
    [TASK_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_EVENT
    ADD CONSTRAINT [PK__JBPM_EVE__C4971C0F2BD7957B] PRIMARY KEY (ID_);

CREATE INDEX [FK_EVENT_NODE] ON LRSAdmin.JBPM_EVENT (NODE_);
CREATE INDEX [FK_EVENT_PROCDEF] ON LRSAdmin.JBPM_EVENT (PROCESSDEFINITION_);
CREATE INDEX [FK_EVENT_TASK] ON LRSAdmin.JBPM_EVENT (TASK_);
CREATE INDEX [FK_EVENT_TRANS] ON LRSAdmin.JBPM_EVENT (TRANSITION_);


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

CREATE TABLE LRSAdmin.JBPM_EXCEPTIONHANDLER (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [EXCEPTIONCLASSNAME_] nvarchar(MAX) NULL,
    [TYPE_] char(1) NULL,
    [GRAPHELEMENT_] numeric(19,0) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [GRAPHELEMENTINDEX_] int NULL,
    [NODE_] numeric(19,0) NULL,
    [TRANSITION_] numeric(19,0) NULL,
    [TASK_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_EXCEPTIONHANDLER
    ADD CONSTRAINT [PK__JBPM_EXC__C4971C0F662D0C68] PRIMARY KEY (ID_);


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

CREATE TABLE LRSAdmin.JBPM_JOB (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [VERSION_] int NOT NULL,
    [DUEDATE_] datetime NULL,
    [PROCESSINSTANCE_] numeric(19,0) NULL,
    [TOKEN_] numeric(19,0) NULL,
    [TASKINSTANCE_] numeric(19,0) NULL,
    [ISSUSPENDED_] tinyint NULL,
    [ISEXCLUSIVE_] tinyint NULL,
    [LOCKOWNER_] nvarchar(255) NULL,
    [LOCKTIME_] datetime NULL,
    [EXCEPTION_] nvarchar(MAX) NULL,
    [RETRIES_] int NULL,
    [NAME_] nvarchar(255) NULL,
    [REPEAT_] nvarchar(255) NULL,
    [TRANSITIONNAME_] nvarchar(255) NULL,
    [ACTION_] numeric(19,0) NULL,
    [GRAPHELEMENTTYPE_] nvarchar(255) NULL,
    [GRAPHELEMENT_] numeric(19,0) NULL,
    [NODE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_JOB
    ADD CONSTRAINT [PK__JBPM_JOB__C4971C0FA2062DE0] PRIMARY KEY (ID_);

CREATE INDEX [FK_JOB_ACTION] ON LRSAdmin.JBPM_JOB (ACTION_);
CREATE INDEX [FK_JOB_NODE] ON LRSAdmin.JBPM_JOB (NODE_);
CREATE INDEX [FK_JOB_PRINST] ON LRSAdmin.JBPM_JOB (PROCESSINSTANCE_);
CREATE INDEX [FK_JOB_TOKEN] ON LRSAdmin.JBPM_JOB (TOKEN_);
CREATE INDEX [FK_JOB_TSKINST] ON LRSAdmin.JBPM_JOB (TASKINSTANCE_);


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

CREATE TABLE LRSAdmin.JBPM_LOG (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [INDEX_] int NULL,
    [DATE_] datetime NULL,
    [TOKEN_] numeric(19,0) NULL,
    [PARENT_] numeric(19,0) NULL,
    [MESSAGE_] nvarchar(MAX) NULL,
    [EXCEPTION_] nvarchar(MAX) NULL,
    [ACTION_] numeric(19,0) NULL,
    [NODE_] numeric(19,0) NULL,
    [ENTER_] datetime NULL,
    [LEAVE_] datetime NULL,
    [DURATION_] numeric(19,0) NULL,
    [NEWLONGVALUE_] numeric(19,0) NULL,
    [TRANSITION_] numeric(19,0) NULL,
    [CHILD_] numeric(19,0) NULL,
    [SOURCENODE_] numeric(19,0) NULL,
    [DESTINATIONNODE_] numeric(19,0) NULL,
    [VARIABLEINSTANCE_] numeric(19,0) NULL,
    [OLDBYTEARRAY_] numeric(19,0) NULL,
    [NEWBYTEARRAY_] numeric(19,0) NULL,
    [OLDDATEVALUE_] datetime NULL,
    [NEWDATEVALUE_] datetime NULL,
    [OLDDOUBLEVALUE_] float NULL,
    [NEWDOUBLEVALUE_] float NULL,
    [OLDLONGIDCLASS_] nvarchar(255) NULL,
    [OLDLONGIDVALUE_] numeric(19,0) NULL,
    [NEWLONGIDCLASS_] nvarchar(255) NULL,
    [NEWLONGIDVALUE_] numeric(19,0) NULL,
    [OLDSTRINGIDCLASS_] nvarchar(255) NULL,
    [OLDSTRINGIDVALUE_] nvarchar(255) NULL,
    [NEWSTRINGIDCLASS_] nvarchar(255) NULL,
    [NEWSTRINGIDVALUE_] nvarchar(255) NULL,
    [OLDLONGVALUE_] numeric(19,0) NULL,
    [OLDSTRINGVALUE_] nvarchar(MAX) NULL,
    [NEWSTRINGVALUE_] nvarchar(MAX) NULL,
    [TASKINSTANCE_] numeric(19,0) NULL,
    [TASKACTORID_] nvarchar(255) NULL,
    [TASKOLDACTORID_] nvarchar(255) NULL,
    [SWIMLANEINSTANCE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_LOG
    ADD CONSTRAINT [PK__JBPM_LOG__C4971C0FAA8BB7C2] PRIMARY KEY (ID_);

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


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

CREATE TABLE LRSAdmin.JBPM_MODULEDEFINITION (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [STARTTASK_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_MODULEDEFINITION
    ADD CONSTRAINT [PK__JBPM_MOD__C4971C0FAC64DDA0] PRIMARY KEY (ID_);

CREATE INDEX [FK_MODDEF_PROCDEF] ON LRSAdmin.JBPM_MODULEDEFINITION (PROCESSDEFINITION_);
CREATE INDEX [FK_TSKDEF_START] ON LRSAdmin.JBPM_MODULEDEFINITION (STARTTASK_);


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

CREATE TABLE LRSAdmin.JBPM_MODULEINSTANCE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [VERSION_] int NOT NULL,
    [PROCESSINSTANCE_] numeric(19,0) NULL,
    [TASKMGMTDEFINITION_] numeric(19,0) NULL,
    [NAME_] nvarchar(255) NULL
);

ALTER TABLE LRSAdmin.JBPM_MODULEINSTANCE
    ADD CONSTRAINT [PK__JBPM_MOD__C4971C0F8AC63619] PRIMARY KEY (ID_);

CREATE INDEX [FK_MODINST_PRCINST] ON LRSAdmin.JBPM_MODULEINSTANCE (PROCESSINSTANCE_);
CREATE INDEX [FK_TASKMGTINST_TMD] ON LRSAdmin.JBPM_MODULEINSTANCE (TASKMGMTDEFINITION_);


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

CREATE TABLE LRSAdmin.JBPM_NODE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [DESCRIPTION_] nvarchar(MAX) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [ISASYNC_] tinyint NULL,
    [ISASYNCEXCL_] tinyint NULL,
    [ACTION_] numeric(19,0) NULL,
    [SUPERSTATE_] numeric(19,0) NULL,
    [SUBPROCNAME_] nvarchar(255) NULL,
    [SUBPROCESSDEFINITION_] numeric(19,0) NULL,
    [DECISIONEXPRESSION_] nvarchar(255) NULL,
    [DECISIONDELEGATION] numeric(19,0) NULL,
    [SCRIPT_] numeric(19,0) NULL,
    [PARENTLOCKMODE_] nvarchar(255) NULL,
    [SIGNAL_] int NULL,
    [CREATETASKS_] tinyint NULL,
    [ENDTASKS_] tinyint NULL,
    [NODECOLLECTIONINDEX_] int NULL
);

ALTER TABLE LRSAdmin.JBPM_NODE
    ADD CONSTRAINT [PK__JBPM_NOD__C4971C0FC87B38AE] PRIMARY KEY (ID_);

CREATE INDEX [FK_DECISION_DELEG] ON LRSAdmin.JBPM_NODE (DECISIONDELEGATION);
CREATE INDEX [FK_NODE_ACTION] ON LRSAdmin.JBPM_NODE (ACTION_);
CREATE INDEX [FK_NODE_PROCDEF] ON LRSAdmin.JBPM_NODE (PROCESSDEFINITION_);
CREATE INDEX [FK_NODE_SCRIPT] ON LRSAdmin.JBPM_NODE (SCRIPT_);
CREATE INDEX [FK_NODE_SUPERSTATE] ON LRSAdmin.JBPM_NODE (SUPERSTATE_);
CREATE INDEX [FK_PROCST_SBPRCDEF] ON LRSAdmin.JBPM_NODE (SUBPROCESSDEFINITION_);


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

CREATE TABLE LRSAdmin.JBPM_POOLEDACTOR (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [ACTORID_] nvarchar(255) NULL,
    [SWIMLANEINSTANCE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_POOLEDACTOR
    ADD CONSTRAINT [PK__JBPM_POO__C4971C0F9B5ED54D] PRIMARY KEY (ID_);

CREATE INDEX [FK_POOLEDACTOR_SLI] ON LRSAdmin.JBPM_POOLEDACTOR (SWIMLANEINSTANCE_);


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

CREATE TABLE LRSAdmin.JBPM_PROCESSDEFINITION (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [DESCRIPTION_] nvarchar(MAX) NULL,
    [VERSION_] int NULL,
    [ISTERMINATIONIMPLICIT_] tinyint NULL,
    [STARTSTATE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_PROCESSDEFINITION
    ADD CONSTRAINT [PK__JBPM_PRO__C4971C0F0D2B1EA7] PRIMARY KEY (ID_);

CREATE INDEX [FK_PROCDEF_STRTSTA] ON LRSAdmin.JBPM_PROCESSDEFINITION (STARTSTATE_);


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

CREATE TABLE LRSAdmin.JBPM_PROCESSINSTANCE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [KEY_] nvarchar(255) NULL,
    [START_] datetime NULL,
    [END_] datetime NULL,
    [ISSUSPENDED_] tinyint NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [ROOTTOKEN_] numeric(19,0) NULL,
    [SUPERPROCESSTOKEN_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_PROCESSINSTANCE
    ADD CONSTRAINT [PK__JBPM_PRO__C4971C0FA0AFF7CD] PRIMARY KEY (ID_);

CREATE INDEX [FK_PROCIN_PROCDEF] ON LRSAdmin.JBPM_PROCESSINSTANCE (PROCESSDEFINITION_);
CREATE INDEX [FK_PROCIN_ROOTTKN] ON LRSAdmin.JBPM_PROCESSINSTANCE (ROOTTOKEN_);
CREATE INDEX [FK_PROCIN_SPROCTKN] ON LRSAdmin.JBPM_PROCESSINSTANCE (SUPERPROCESSTOKEN_);


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

CREATE TABLE LRSAdmin.JBPM_RUNTIMEACTION (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [EVENTTYPE_] nvarchar(255) NULL,
    [TYPE_] char(1) NULL,
    [GRAPHELEMENT_] numeric(19,0) NULL,
    [PROCESSINSTANCE_] numeric(19,0) NULL,
    [ACTION_] numeric(19,0) NULL,
    [PROCESSINSTANCEINDEX_] int NULL
);

ALTER TABLE LRSAdmin.JBPM_RUNTIMEACTION
    ADD CONSTRAINT [PK__JBPM_RUN__C4971C0FA44DB536] PRIMARY KEY (ID_);

CREATE INDEX [FK_RTACTN_ACTION] ON LRSAdmin.JBPM_RUNTIMEACTION (ACTION_);
CREATE INDEX [FK_RTACTN_PROCINST] ON LRSAdmin.JBPM_RUNTIMEACTION (PROCESSINSTANCE_);


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

CREATE TABLE LRSAdmin.JBPM_SWIMLANE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [ACTORIDEXPRESSION_] nvarchar(255) NULL,
    [POOLEDACTORSEXPRESSION_] nvarchar(255) NULL,
    [ASSIGNMENTDELEGATION_] numeric(19,0) NULL,
    [TASKMGMTDEFINITION_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_SWIMLANE
    ADD CONSTRAINT [PK__JBPM_SWI__C4971C0F9C091E53] PRIMARY KEY (ID_);

CREATE INDEX [FK_SWL_ASSDEL] ON LRSAdmin.JBPM_SWIMLANE (ASSIGNMENTDELEGATION_);
CREATE INDEX [FK_SWL_TSKMGMTDEF] ON LRSAdmin.JBPM_SWIMLANE (TASKMGMTDEFINITION_);


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

CREATE TABLE LRSAdmin.JBPM_SWIMLANEINSTANCE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [ACTORID_] nvarchar(255) NULL,
    [SWIMLANE_] numeric(19,0) NULL,
    [TASKMGMTINSTANCE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_SWIMLANEINSTANCE
    ADD CONSTRAINT [PK__JBPM_SWI__C4971C0F6EF0B972] PRIMARY KEY (ID_);

CREATE INDEX [FK_SWIMLANEINST_SL] ON LRSAdmin.JBPM_SWIMLANEINSTANCE (SWIMLANE_);
CREATE INDEX [FK_SWIMLANEINST_TM] ON LRSAdmin.JBPM_SWIMLANEINSTANCE (TASKMGMTINSTANCE_);


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

CREATE TABLE LRSAdmin.JBPM_TASK (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [DESCRIPTION_] nvarchar(MAX) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [ISBLOCKING_] tinyint NULL,
    [ISSIGNALLING_] tinyint NULL,
    [CONDITION_] nvarchar(255) NULL,
    [DUEDATE_] nvarchar(255) NULL,
    [PRIORITY_] int NULL,
    [ACTORIDEXPRESSION_] nvarchar(255) NULL,
    [POOLEDACTORSEXPRESSION_] nvarchar(255) NULL,
    [TASKMGMTDEFINITION_] numeric(19,0) NULL,
    [TASKNODE_] numeric(19,0) NULL,
    [STARTSTATE_] numeric(19,0) NULL,
    [ASSIGNMENTDELEGATION_] numeric(19,0) NULL,
    [SWIMLANE_] numeric(19,0) NULL,
    [TASKCONTROLLER_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_TASK
    ADD CONSTRAINT [PK__JBPM_TAS__C4971C0FDBE2EE54] PRIMARY KEY (ID_);

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


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

CREATE TABLE LRSAdmin.JBPM_TASKACTORPOOL (
    [TASKINSTANCE_] numeric(19,0) NOT NULL,
    [POOLEDACTOR_] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.JBPM_TASKACTORPOOL
    ADD CONSTRAINT [PK__JBPM_TAS__AE563B953F482496] PRIMARY KEY (TASKINSTANCE_, POOLEDACTOR_);

CREATE INDEX [FK_TASKACTPL_TSKI] ON LRSAdmin.JBPM_TASKACTORPOOL (TASKINSTANCE_);
CREATE INDEX [FK_TSKACTPOL_PLACT] ON LRSAdmin.JBPM_TASKACTORPOOL (POOLEDACTOR_);


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

CREATE TABLE LRSAdmin.JBPM_TASKCONTROLLER (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [TASKCONTROLLERDELEGATION_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_TASKCONTROLLER
    ADD CONSTRAINT [PK__JBPM_TAS__C4971C0F2AED0114] PRIMARY KEY (ID_);

CREATE INDEX [FK_TSKCTRL_DELEG] ON LRSAdmin.JBPM_TASKCONTROLLER (TASKCONTROLLERDELEGATION_);


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

CREATE TABLE LRSAdmin.JBPM_TASKINSTANCE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [VERSION_] int NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [DESCRIPTION_] nvarchar(MAX) NULL,
    [ACTORID_] nvarchar(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_] numeric(19,0) NULL,
    [TOKEN_] numeric(19,0) NULL,
    [PROCINST_] numeric(19,0) NULL,
    [SWIMLANINSTANCE_] numeric(19,0) NULL,
    [TASKMGMTINSTANCE_] numeric(19,0) NULL,
    [JBPM_ENGINE_NAME] nvarchar(50) NULL
);

ALTER TABLE LRSAdmin.JBPM_TASKINSTANCE
    ADD CONSTRAINT [PK__JBPM_TAS__C4971C0F707C5915] PRIMARY KEY (ID_);

CREATE INDEX [FK_TASKINST_SLINST] ON LRSAdmin.JBPM_TASKINSTANCE (SWIMLANINSTANCE_);
CREATE INDEX [FK_TASKINST_TASK] ON LRSAdmin.JBPM_TASKINSTANCE (TASK_);
CREATE INDEX [FK_TASKINST_TMINST] ON LRSAdmin.JBPM_TASKINSTANCE (TASKMGMTINSTANCE_);
CREATE INDEX [FK_TASKINST_TOKEN] ON LRSAdmin.JBPM_TASKINSTANCE (TOKEN_);
CREATE INDEX [FK_TSKINS_PRCINS] ON LRSAdmin.JBPM_TASKINSTANCE (PROCINST_);


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

CREATE TABLE LRSAdmin.JBPM_TOKEN (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [START_] datetime NULL,
    [END_] datetime NULL,
    [NODEENTER_] datetime NULL,
    [NEXTLOGINDEX_] int NULL,
    [ISABLETOREACTIVATEPARENT_] tinyint NULL,
    [ISTERMINATIONIMPLICIT_] tinyint NULL,
    [ISSUSPENDED_] tinyint NULL,
    [LOCK_] nvarchar(255) NULL,
    [NODE_] numeric(19,0) NULL,
    [PROCESSINSTANCE_] numeric(19,0) NULL,
    [PARENT_] numeric(19,0) NULL,
    [SUBPROCESSINSTANCE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_TOKEN
    ADD CONSTRAINT [PK__JBPM_TOK__C4971C0F6733F10F] PRIMARY KEY (ID_);

CREATE INDEX [FK_TOKEN_NODE] ON LRSAdmin.JBPM_TOKEN (NODE_);
CREATE INDEX [FK_TOKEN_PARENT] ON LRSAdmin.JBPM_TOKEN (PARENT_);
CREATE INDEX [FK_TOKEN_PROCINST] ON LRSAdmin.JBPM_TOKEN (PROCESSINSTANCE_);
CREATE INDEX [FK_TOKEN_SUBPI] ON LRSAdmin.JBPM_TOKEN (SUBPROCESSINSTANCE_);


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

CREATE TABLE LRSAdmin.JBPM_TOKENVARIABLEMAP (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VERSION_] int NOT NULL,
    [TOKEN_] numeric(19,0) NULL,
    [CONTEXTINSTANCE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_TOKENVARIABLEMAP
    ADD CONSTRAINT [PK__JBPM_TOK__C4971C0F0958EAC3] PRIMARY KEY (ID_);

CREATE INDEX [FK_TKVARMAP_CTXT] ON LRSAdmin.JBPM_TOKENVARIABLEMAP (CONTEXTINSTANCE_);
CREATE INDEX [FK_TKVARMAP_TOKEN] ON LRSAdmin.JBPM_TOKENVARIABLEMAP (TOKEN_);


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

CREATE TABLE LRSAdmin.JBPM_TRANSITION (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [DESCRIPTION_] nvarchar(MAX) NULL,
    [PROCESSDEFINITION_] numeric(19,0) NULL,
    [FROM_] numeric(19,0) NULL,
    [TO_] numeric(19,0) NULL,
    [CONDITION_] nvarchar(255) NULL,
    [FROMINDEX_] int NULL
);

ALTER TABLE LRSAdmin.JBPM_TRANSITION
    ADD CONSTRAINT [PK__JBPM_TRA__C4971C0F74987A6F] PRIMARY KEY (ID_);

CREATE INDEX [FK_TRANS_PROCDEF] ON LRSAdmin.JBPM_TRANSITION (PROCESSDEFINITION_);
CREATE INDEX [FK_TRANSITION_FROM] ON LRSAdmin.JBPM_TRANSITION (FROM_);
CREATE INDEX [FK_TRANSITION_TO] ON LRSAdmin.JBPM_TRANSITION (TO_);


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

CREATE TABLE LRSAdmin.JBPM_VARIABLEACCESS (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [VARIABLENAME_] nvarchar(255) NULL,
    [ACCESS_] nvarchar(255) NULL,
    [MAPPEDNAME_] nvarchar(255) NULL,
    [PROCESSSTATE_] numeric(19,0) NULL,
    [TASKCONTROLLER_] numeric(19,0) NULL,
    [INDEX_] int NULL,
    [SCRIPT_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_VARIABLEACCESS
    ADD CONSTRAINT [PK__JBPM_VAR__C4971C0FA603DB80] PRIMARY KEY (ID_);

CREATE INDEX [FK_VARACC_PROCST] ON LRSAdmin.JBPM_VARIABLEACCESS (PROCESSSTATE_);
CREATE INDEX [FK_VARACC_SCRIPT] ON LRSAdmin.JBPM_VARIABLEACCESS (SCRIPT_);
CREATE INDEX [FK_VARACC_TSKCTRL] ON LRSAdmin.JBPM_VARIABLEACCESS (TASKCONTROLLER_);


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

CREATE TABLE LRSAdmin.JBPM_VARIABLEINSTANCE (
    [ID_] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [CLASS_] char(1) NOT NULL,
    [VERSION_] int NOT NULL,
    [NAME_] nvarchar(255) NULL,
    [CONVERTER_] char(1) NULL,
    [TOKEN_] numeric(19,0) NULL,
    [TOKENVARIABLEMAP_] numeric(19,0) NULL,
    [PROCESSINSTANCE_] numeric(19,0) NULL,
    [BYTEARRAYVALUE_] numeric(19,0) NULL,
    [DATEVALUE_] datetime NULL,
    [DOUBLEVALUE_] float NULL,
    [LONGIDCLASS_] nvarchar(255) NULL,
    [LONGVALUE_] numeric(19,0) NULL,
    [STRINGIDCLASS_] nvarchar(255) NULL,
    [STRINGVALUE_] nvarchar(255) NULL,
    [TASKINSTANCE_] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.JBPM_VARIABLEINSTANCE
    ADD CONSTRAINT [PK__JBPM_VAR__C4971C0FA7B2777C] PRIMARY KEY (ID_);

CREATE INDEX [FK_BYTEINST_ARRAY] ON LRSAdmin.JBPM_VARIABLEINSTANCE (BYTEARRAYVALUE_);
CREATE INDEX [FK_VAR_TSKINST] ON LRSAdmin.JBPM_VARIABLEINSTANCE (TASKINSTANCE_);
CREATE INDEX [FK_VARINST_PRCINST] ON LRSAdmin.JBPM_VARIABLEINSTANCE (PROCESSINSTANCE_);
CREATE INDEX [FK_VARINST_TK] ON LRSAdmin.JBPM_VARIABLEINSTANCE (TOKEN_);
CREATE INDEX [FK_VARINST_TKVARMP] ON LRSAdmin.JBPM_VARIABLEINSTANCE (TOKENVARIABLEMAP_);


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

CREATE TABLE LRSAdmin.JMS_MESSAGES (
    [MESSAGEID] int NOT NULL,
    [DESTINATION] varchar(1024) NOT NULL,
    [TXID] int NULL,
    [TXOP] char(1) NULL,
    [MESSAGEBLOB] image NULL
);

CREATE INDEX [JMS_MESSAGES_DESTINATION] ON LRSAdmin.JMS_MESSAGES (DESTINATION);
CREATE UNIQUE INDEX [JMS_MESSAGES_IDX] ON LRSAdmin.JMS_MESSAGES (MESSAGEID, DESTINATION);
CREATE INDEX [JMS_MESSAGES_TXOP_TXID] ON LRSAdmin.JMS_MESSAGES (TXOP, TXID);


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

CREATE TABLE LRSAdmin.JMS_ROLES (
    [ROLEID] varchar(32) NOT NULL,
    [USERID] varchar(32) NOT NULL
);

ALTER TABLE LRSAdmin.JMS_ROLES
    ADD CONSTRAINT [PK__JMS_ROLE__FB9829BBD44D175D] PRIMARY KEY (USERID, ROLEID);


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

CREATE TABLE LRSAdmin.JMS_SUBSCRIPTIONS (
    [CLIENTID] varchar(128) NOT NULL,
    [SUBNAME] varchar(128) NOT NULL,
    [TOPIC] varchar(255) NOT NULL,
    [SELECTOR] varchar(255) NULL
);

ALTER TABLE LRSAdmin.JMS_SUBSCRIPTIONS
    ADD CONSTRAINT [PK__JMS_SUBS__1FF24DBCBFA458AC] PRIMARY KEY (CLIENTID, SUBNAME);


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

CREATE TABLE LRSAdmin.JMS_TRANSACTIONS (
    [TXID] int NOT NULL
);

ALTER TABLE LRSAdmin.JMS_TRANSACTIONS
    ADD CONSTRAINT [PK__JMS_TRAN__827BEF0EDBC47310] PRIMARY KEY (TXID);


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

CREATE TABLE LRSAdmin.JMS_USERS (
    [USERID] varchar(32) NOT NULL,
    [PASSWD] varchar(32) NOT NULL,
    [CLIENTID] varchar(128) NULL
);

ALTER TABLE LRSAdmin.JMS_USERS
    ADD CONSTRAINT [PK__JMS_USER__7B9E7F35CDACCA28] PRIMARY KEY (USERID);


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

CREATE TABLE LRSAdmin.lr_address (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [address_area_name] nvarchar(250) NULL,
    [street_number] nvarchar(50) NULL,
    [street_name] nvarchar(100) NULL,
    [building_name] nvarchar(50) NULL,
    [building_number] int NULL,
    [layout_name] numeric(19,0) NULL,
    [postal_code] nvarchar(10) NULL,
    [city] nvarchar(100) NULL,
    [ward] nvarchar(100) NULL,
    [cell] nvarchar(100) NULL,
    [local_government_area] numeric(19,0) NULL,
    [country] numeric(19,0) NOT NULL,
    [region] numeric(19,0) NOT NULL,
    [origin_region] numeric(19,0) NULL,
    [district] numeric(19,0) NOT NULL,
    [cadregion] numeric(19,0) NOT NULL,
    [subdistrict] numeric(19,0) NOT NULL,
    [subcounty] nvarchar(30) NULL,
    [address_line1] nvarchar(50) NULL,
    [address_line2] nvarchar(100) NULL,
    [address_line3] nvarchar(100) NULL,
    [district_text] nvarchar(100) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_address
    ADD CONSTRAINT [PK__lr_addre__3213E83F6872A593] PRIMARY KEY (id);

CREATE INDEX [lr_address_city_idx] ON LRSAdmin.lr_address (city);
CREATE INDEX [lr_address_district_idx] ON LRSAdmin.lr_address (district);
CREATE INDEX [lr_address_region_idx] ON LRSAdmin.lr_address (region);
CREATE INDEX [lr_address_street_name_idx] ON LRSAdmin.lr_address (street_name);


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

CREATE TABLE LRSAdmin.lr_admin_document_party (
    [document] numeric(19,0) NOT NULL,
    [party] numeric(19,0) NOT NULL,
    [party_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_admin_document_party
    ADD CONSTRAINT [PK__lr_admin__FC70D9A9500F9FF4] PRIMARY KEY (document, party_index);


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

CREATE TABLE LRSAdmin.lr_admin_document_rrr (
    [document] numeric(19,0) NOT NULL,
    [rrr] numeric(19,0) NOT NULL,
    [rrr_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_admin_document_rrr
    ADD CONSTRAINT [PK__lr_admin__1BEF61927B6B04FA] PRIMARY KEY (document, rrr_index);


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

CREATE TABLE LRSAdmin.lr_admin_source_document (
    [id] numeric(19,0) NOT NULL,
    [purchase_price] float NULL,
    [memo_text] nvarchar(2500) NULL
);

ALTER TABLE LRSAdmin.lr_admin_source_document
    ADD CONSTRAINT [PK__lr_admin__3213E83F96542700] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_applicant (
    [id] numeric(19,0) NOT NULL,
    [application_type] numeric(19,0) NOT NULL,
    [delivery_type] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.lr_applicant
    ADD CONSTRAINT [PK__lr_appli__3213E83FA30AC0EE] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_batch (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [batch_number] nvarchar(50) NULL,
    [application_status] numeric(19,0) NOT NULL,
    [invoice_number] nvarchar(150) NULL,
    [create_date] datetime NULL,
    [delivery_date] datetime NULL,
    [office] numeric(19,0) NULL,
    [comments] nvarchar(800) NULL,
    [decision] nvarchar(100) NULL,
    [decision_date] datetime NULL,
    [decision_number] nvarchar(50) NULL,
    [attachments] nvarchar(255) NULL,
    [registrar] nvarchar(50) NULL,
    [registration_date] datetime NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_batch
    ADD CONSTRAINT [PK__lr_batch__3213E83F7DF19F79] PRIMARY KEY (id);

CREATE INDEX [lr_batch_batch_status_idx] ON LRSAdmin.lr_batch (application_status);
CREATE INDEX [lr_batch_office_idx] ON LRSAdmin.lr_batch (office);


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

CREATE TABLE LRSAdmin.lr_batch_party (
    [batch] numeric(19,0) NOT NULL,
    [party] numeric(19,0) NOT NULL,
    [party_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_batch_party
    ADD CONSTRAINT [PK__lr_batch__7B90C77A3264FB65] PRIMARY KEY (batch, party_index);

CREATE INDEX [lr_batch_party__idx] ON LRSAdmin.lr_batch_party (batch, party);


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

CREATE TABLE LRSAdmin.lr_batch_related (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [parent_id] numeric(19,0) NOT NULL,
    [child_id] numeric(19,0) NOT NULL,
    [process_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_batch_related
    ADD CONSTRAINT [PK__lr_batch__3213E83F8FBA7294] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_billing (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [invoice_number] nvarchar(50) NULL,
    [total_amount] float NULL,
    [status] numeric(19,0) NOT NULL,
    [invoice_type] numeric(19,0) NOT NULL,
    [wires_trx_id] numeric(19,0) NULL,
    [wrx_date_submitted] datetime NULL,
    [wrx_date_accepted] datetime NULL,
    [due_date] datetime NULL,
    [party] numeric(19,0) NULL,
    [party_contact] numeric(19,0) NULL,
    [ref_number] nvarchar(50) NULL,
    [description] nvarchar(800) NULL,
    [comments] nvarchar(800) NULL,
    [submitted_by] nvarchar(50) NULL,
    [bil1] nvarchar(50) NULL,
    [bil2] nvarchar(50) NULL,
    [bil_dict1] numeric(19,0) NOT NULL,
    [bil_dict2] numeric(19,0) NOT NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_billing
    ADD CONSTRAINT [PK__lr_billi__3213E83F7730DC45] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_billing_dist_line (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [trans_code] nvarchar(50) NULL,
    [amount] float NULL,
    [flex_field_1] nvarchar(250) NULL,
    [flex_field_2] nvarchar(250) NULL,
    [flex_field_3] nvarchar(250) NULL,
    [flex_field_4] nvarchar(250) NULL,
    [flex_field_5] nvarchar(250) NULL,
    [wires_dist_line_id] nvarchar(50) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [line_id] numeric(19,0) NULL,
    [line_index] int NULL
);

ALTER TABLE LRSAdmin.lr_billing_dist_line
    ADD CONSTRAINT [PK__lr_billi__3213E83F44848EE7] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_billing_line (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [line_type] nvarchar(50) NULL,
    [quantity] float NULL,
    [amount] float NULL,
    [total_amount] float NULL,
    [wires_line_id] nvarchar(50) NULL,
    [description] nvarchar(800) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [bill_id] numeric(19,0) NULL,
    [bill_index] int NULL
);

ALTER TABLE LRSAdmin.lr_billing_line
    ADD CONSTRAINT [PK__lr_billi__3213E83FBC0C2018] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_building (
    [id] numeric(19,0) NOT NULL,
    [compl_number] nvarchar(30) NULL,
    [actual_use_type] numeric(19,0) NOT NULL,
    [number_of_units] int NULL,
    [number_of_floors] int NULL,
    [floor_area] float NULL,
    [floor_area_unit_type] numeric(19,0) NOT NULL,
    [internal_area] float NULL,
    [internal_area_unit_type] numeric(19,0) NOT NULL,
    [unit_factor] int NULL,
    [adjacents] nvarchar(500) NULL,
    [build_category] numeric(19,0) NOT NULL,
    [build_purpose] numeric(19,0) NOT NULL,
    [build_date1] datetime NULL,
    [build_date2] datetime NULL
);

ALTER TABLE LRSAdmin.lr_building
    ADD CONSTRAINT [PK__lr_build__3213E83FC46ED5CC] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_building_unit (
    [id] numeric(19,0) NOT NULL,
    [unit_number] nvarchar(30) NULL,
    [building_number] nvarchar(30) NULL,
    [compl_number] nvarchar(30) NULL,
    [condo_plan] nvarchar(20) NULL,
    [use_type] numeric(19,0) NOT NULL,
    [bunit_type] numeric(19,0) NULL,
    [bunit_category] numeric(19,0) NOT NULL,
    [bunit_purpose] numeric(19,0) NOT NULL,
    [use_typespecificbld] nvarchar(50) NULL,
    [unit_factor] int NULL,
    [unit_type] numeric(19,0) NOT NULL,
    [number_of_units] int NULL,
    [number_of_floors] int NULL,
    [floor_type] numeric(19,0) NOT NULL,
    [floor_area] float NULL,
    [floor_area_unit_type] numeric(19,0) NOT NULL,
    [internal_area] float NULL,
    [internal_area_unit_type] numeric(19,0) NOT NULL,
    [adjacents] nvarchar(500) NULL,
    [bunit1] nvarchar(50) NULL,
    [bunit2] nvarchar(50) NULL,
    [bunit_dict1] numeric(19,0) NOT NULL,
    [bunit_dict2] numeric(19,0) NOT NULL,
    [bunit_date1] datetime NULL,
    [bunit_date2] datetime NULL,
    [bunit_count1] int NULL,
    [bunit_count2] int NULL,
    [plot_uid] nvarchar(50) NULL
);

ALTER TABLE LRSAdmin.lr_building_unit
    ADD CONSTRAINT [PK__lr_build__3213E83FDC7F7700] PRIMARY KEY (id);

CREATE INDEX [lr_building_unit_use_type_idx] ON LRSAdmin.lr_building_unit (use_type);


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

CREATE TABLE LRSAdmin.lr_business_calendar (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [code] nvarchar(255) NOT NULL,
    [label] nvarchar(255) NOT NULL,
    [day_part] nvarchar(500) NULL
);

ALTER TABLE LRSAdmin.lr_business_calendar
    ADD CONSTRAINT [PK__lr_busin__3214EC072C47328F] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_condition (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [condition_type] numeric(19,0) NOT NULL,
    [condition_seq] numeric(19,0) NULL,
    [condition_number] nvarchar(100) NULL,
    [cond_stage] nvarchar(150) NULL,
    [condition_text] nvarchar(1500) NULL,
    [original_text] nvarchar(1000) NULL,
    [custom_condition] tinyint NULL,
    [last_edited_by] nvarchar(255) NULL,
    [sign_by] nvarchar(100) NULL,
    [validated_by] nvarchar(100) NULL,
    [last_edited] datetime NULL,
    [received_date] datetime NULL,
    [validated_date] datetime NULL,
    [monitored] tinyint NULL,
    [cond_status] numeric(19,0) NOT NULL,
    [cond1] nvarchar(50) NULL,
    [cond2] nvarchar(50) NULL,
    [cond_dict1] numeric(19,0) NOT NULL,
    [cond_dict2] numeric(19,0) NOT NULL,
    [cond_count1] int NULL,
    [cond_count2] int NULL,
    [transaction_] numeric(19,0) NULL,
    [condition_index] int NULL
);

ALTER TABLE LRSAdmin.lr_condition
    ADD CONSTRAINT [PK__lr_condi__3213E83F05064C95] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_contact (
    [id] numeric(19,0) NOT NULL,
    [contact_type] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.lr_contact
    ADD CONSTRAINT [PK__lr_conta__3213E83F98CC3DCD] PRIMARY KEY (id);

CREATE INDEX [lr_contact_contact_type_idx] ON LRSAdmin.lr_contact (contact_type);


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

CREATE TABLE LRSAdmin.lr_corporation (
    [id] numeric(19,0) NOT NULL,
    [name] nvarchar(150) NULL,
    [represent_name] nvarchar(50) NULL,
    [gsm_number] nvarchar(50) NULL,
    [cac_number] nvarchar(50) NULL,
    [corp1] nvarchar(50) NULL,
    [corp2] nvarchar(50) NULL,
    [corp_dict1] numeric(19,0) NOT NULL,
    [corp_dict2] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.lr_corporation
    ADD CONSTRAINT [PK__lr_corpo__3213E83FDCC2D0FA] PRIMARY KEY (id);

CREATE INDEX [lr_corporation_name_idx] ON LRSAdmin.lr_corporation (name);


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

CREATE TABLE LRSAdmin.lr_dictionary (
    [Id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [code] nvarchar(64) NOT NULL,
    [label] nvarchar(254) NOT NULL,
    [descr] nvarchar(1000) NULL,
    [category] nvarchar(64) NOT NULL,
    [general_term] tinyint NULL,
    [sort_order] int NULL,
    [hidden] tinyint NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [label_lang] nvarchar(254) NULL,
    [descr_lang] nvarchar(1000) NULL,
    [parentcode] nvarchar(64) NULL
);

ALTER TABLE LRSAdmin.lr_dictionary
    ADD CONSTRAINT [PK__lr_dicti__3214EC0729C33D08] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_document_ext (
    [parent_id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [extended_comments] nvarchar(2000) NULL,
    [extended_params] nvarchar(1000) NULL
);

ALTER TABLE LRSAdmin.lr_document_ext
    ADD CONSTRAINT [PK__lr_docum__F2A6081919284BA1] PRIMARY KEY (parent_id);


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

CREATE TABLE LRSAdmin.lr_extension_link (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [parent_class] nvarchar(255) NOT NULL,
    [child_class] nvarchar(255) NOT NULL
);

ALTER TABLE LRSAdmin.lr_extension_link
    ADD CONSTRAINT [PK__lr_exten__3213E83F7F73E9EC] PRIMARY KEY (id);

CREATE UNIQUE INDEX [UQ__lr_exten__0EC99930AAD3FD41] ON LRSAdmin.lr_extension_link (parent_class);
CREATE UNIQUE INDEX [UQ__lr_exten__E5D6DD2CD39A8F92] ON LRSAdmin.lr_extension_link (child_class);


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

CREATE TABLE LRSAdmin.lr_fee_rate (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [fee_name] numeric(19,0) NOT NULL,
    [transaction_type] numeric(19,0) NULL,
    [area] numeric(19,0) NULL,
    [size] numeric(19,2) NULL,
    [measuremente_unit_type] numeric(19,0) NULL,
    [location] numeric(19,0) NULL,
    [land_use_type_category] numeric(19,0) NULL,
    [land_use_type] numeric(19,0) NULL,
    [size_range_upper_bound] numeric(19,2) NULL,
    [size_range_lower_bound] numeric(19,2) NULL,
    [size_range_type] numeric(19,0) NULL,
    [rate_type] numeric(19,0) NULL,
    [rate] numeric(19,2) NULL,
    [id_fee_structure] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_fee_rate
    ADD CONSTRAINT [PK__lr_fee_r__3214EC0740E4E9B0] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_fee_structure (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [fee_name] numeric(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
);

ALTER TABLE LRSAdmin.lr_fee_structure
    ADD CONSTRAINT [PK__lr_fee_s__3214EC07C1C690CC] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_formfield (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [form_name] nvarchar(64) NOT NULL,
    [class_name] nvarchar(64) NOT NULL,
    [attribute_name] nvarchar(64) NOT NULL,
    [xsd_type] nvarchar(64) NOT NULL,
    [data_length] int NULL,
    [caption] nvarchar(128) NULL,
    [mandatory] tinyint NULL,
    [category] nvarchar(64) NULL,
    [mru] tinyint NULL,
    [format] nvarchar(255) NULL,
    [format_sample] nvarchar(64) NULL,
    [attribute_precision] int NULL,
    [enabled_for] nvarchar(255) NULL,
    [readonly_for] nvarchar(255) NULL,
    [validation_rule] nvarchar(255) NULL,
    [condition_rule] nvarchar(1500) NULL,
    [multiline] tinyint NULL,
    [language] nvarchar(5) NULL,
    [monolingual] tinyint NULL,
    [group_name] nvarchar(255) NULL,
    [ins_position] nvarchar(1) NULL,
    [description] nvarchar(512) NULL
);

ALTER TABLE LRSAdmin.lr_formfield
    ADD CONSTRAINT [PK__lr_formf__3214EC074D9924A0] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_ground_rent (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [propertyNumber] nvarchar(50) NOT NULL,
    [paidYear] nvarchar(10) NOT NULL,
    [amount] float NULL,
    [paidSum] float NULL
);

ALTER TABLE LRSAdmin.lr_ground_rent
    ADD CONSTRAINT [PK__lr_groun__3214EC07A1DE2703] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_incoming_document (
    [id] numeric(19,0) NOT NULL,
    [establish_right] tinyint NULL
);

ALTER TABLE LRSAdmin.lr_incoming_document
    ADD CONSTRAINT [PK__lr_incom__3213E83F1483D54A] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_individual (
    [id] numeric(19,0) NOT NULL,
    [first_name] nvarchar(150) NULL,
    [second_name] nvarchar(150) NULL,
    [last_name] nvarchar(150) NULL,
    [last_name2] nvarchar(150) NULL,
    [gender] numeric(19,0) NOT NULL,
    [salutation] numeric(19,0) NOT NULL,
    [civil_state] numeric(19,0) NOT NULL,
    [profession] numeric(19,0) NOT NULL,
    [occupation] nvarchar(50) NULL,
    [clan_name] nvarchar(30) NULL,
    [father_name] nvarchar(50) NULL,
    [grandfather_name] nvarchar(50) NULL,
    [paye_number] nvarchar(50) NULL,
    [indiv1] nvarchar(50) NULL,
    [indiv2] nvarchar(50) NULL,
    [indiv_dict1] numeric(19,0) NOT NULL,
    [indiv_dict2] numeric(19,0) NOT NULL,
    [driver_licence_region] numeric(19,0) NOT NULL,
    [driver_licence_number] nvarchar(20) NULL
);

ALTER TABLE LRSAdmin.lr_individual
    ADD CONSTRAINT [PK__lr_indiv__3213E83F63DE9CA8] PRIMARY KEY (id);

CREATE INDEX [lr_individual_gender_idx] ON LRSAdmin.lr_individual (gender);
CREATE INDEX [lr_individual_last_name_idx] ON LRSAdmin.lr_individual (last_name);


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

CREATE TABLE LRSAdmin.lr_launit (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [unit_uid] nvarchar(50) NULL,
    [old_property_id] nvarchar(50) NULL,
    [tenure_type] numeric(19,0) NOT NULL,
    [name] nvarchar(250) NULL,
    [rental_amount] float NULL,
    [build_value] float NULL,
    [build_term] int NULL,
    [register_type] nvarchar(100) NULL,
    [purpose_clause] nvarchar(50) NULL,
    [reg_date] datetime NULL,
    [volumefolio] nvarchar(50) NULL,
    [cert_numbers] nvarchar(1500) NULL,
    [is_exists] tinyint NULL,
    [legal_description] nvarchar(2000) NULL,
    [note] nvarchar(2000) NULL,
    [transaction_cancel] nvarchar(50) NULL,
    [archive_date] datetime NULL,
    [lau_date1] datetime NULL,
    [lau_date2] datetime NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [source_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_launit
    ADD CONSTRAINT [PK__lr_launi__3213E83FC450E627] PRIMARY KEY (id);

CREATE INDEX [lr_launit_old_property_id_idx] ON LRSAdmin.lr_launit (old_property_id);
CREATE INDEX [lr_launit_unit_uid_idx] ON LRSAdmin.lr_launit (unit_uid);
CREATE INDEX [lr_launit_version_idx] ON LRSAdmin.lr_launit (version);


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

CREATE TABLE LRSAdmin.lr_launit_lineage (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [child_id] numeric(19,0) NULL,
    [parent_id] numeric(19,0) NULL,
    [child_uid] nvarchar(50) NULL,
    [parent_uid] nvarchar(50) NOT NULL,
    [transaction_number] nvarchar(50) NULL,
    [transaction_cancel] nvarchar(50) NULL,
    [archive_date] datetime NULL
);

ALTER TABLE LRSAdmin.lr_launit_lineage
    ADD CONSTRAINT [PK__lr_launi__3213E83F20D0C9B3] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_launit_spatial_unit (
    [launit] numeric(19,0) NOT NULL,
    [spatial_unit] numeric(19,0) NOT NULL,
    [unit_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_launit_spatial_unit
    ADD CONSTRAINT [PK__lr_launi__8878425080DF12A1] PRIMARY KEY (launit, unit_index);

CREATE INDEX [lr_launit_spatial_unit__idx] ON LRSAdmin.lr_launit_spatial_unit (launit, spatial_unit);


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

CREATE TABLE LRSAdmin.lr_mc_job (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [job_instance_id] numeric(19,0) NOT NULL,
    [job_id] numeric(19,0) NOT NULL,
    [job_priority] numeric(19,0) NOT NULL,
    [job_name] nvarchar(250) NULL,
    [job_status] int NULL,
    [job_started] datetime NULL,
    [job_updated] datetime NULL,
    [job_ended] datetime NULL,
    [job_comments] nvarchar(800) NULL,
    [job_parameters] nvarchar(2000) NULL,
    [transaction_id] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.lr_mc_job
    ADD CONSTRAINT [PK__lr_mc_jo__3214EC073C646992] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_mortgage (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [amount] float NULL,
    [interest_rate] float NULL,
    [ranking] int NULL,
    [mortgage_type] numeric(19,0) NOT NULL,
    [mrg1] nvarchar(50) NULL,
    [mrg2] nvarchar(50) NULL,
    [mrg_dict1] numeric(19,0) NOT NULL,
    [mrg_dict2] numeric(19,0) NOT NULL,
    [party] numeric(19,0) NULL,
    [right_id] numeric(19,0) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_mortgage
    ADD CONSTRAINT [PK__lr_mortg__3213E83F2408E413] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_parcel (
    [id] numeric(19,0) NOT NULL,
    [actual_use_type] numeric(19,0) NOT NULL,
    [land_type] numeric(19,0) NULL,
    [land_category] numeric(19,0) NOT NULL,
    [land_purpose] numeric(19,0) NOT NULL,
    [survey_plan_no] nvarchar(50) NULL,
    [survey_type] numeric(19,0) NOT NULL,
    [survey_date] datetime NULL,
    [parcel_number] nvarchar(4) NULL,
    [survey_name] nvarchar(32) NULL,
    [boundaries_description] nvarchar(800) NULL,
    [adjacents] nvarchar(500) NULL,
    [use_typespecific] nvarchar(50) NULL,
    [parc1] nvarchar(50) NULL,
    [parc2] nvarchar(50) NULL,
    [parc_dict1] numeric(19,0) NOT NULL,
    [parc_dict2] numeric(19,0) NOT NULL,
    [parc_date1] datetime NULL,
    [parc_date2] datetime NULL,
    [parc_count1] int NULL,
    [parc_count2] int NULL
);

ALTER TABLE LRSAdmin.lr_parcel
    ADD CONSTRAINT [PK__lr_parce__3213E83F249FA76D] PRIMARY KEY (id);

CREATE INDEX [lr_parcel_actual_use_type_idx] ON LRSAdmin.lr_parcel (actual_use_type);


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

CREATE TABLE LRSAdmin.lr_party (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [party_type] numeric(19,0) NOT NULL,
    [party_role_type] numeric(19,0) NOT NULL,
    [name] nvarchar(250) NULL,
    [name2] nvarchar(250) NULL,
    [person] numeric(19,0) NULL,
    [share_nominator] int NULL,
    [share_denominator] int NULL,
    [share_description] nvarchar(250) NULL,
    [shares] nvarchar(255) NULL,
    [share_type] numeric(19,0) NOT NULL,
    [tax_exempt] tinyint NULL,
    [title_holder] tinyint NULL,
    [cert_no] nvarchar(100) NULL,
    [unit_uid] nvarchar(500) NULL,
    [ruid] numeric(19,0) NULL,
    [part1] nvarchar(50) NULL,
    [part2] nvarchar(50) NULL,
    [part_dict1] numeric(19,0) NOT NULL,
    [part_dict2] numeric(19,0) NOT NULL,
    [comments] nvarchar(800) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [source_id] numeric(19,0) NULL,
    [previous_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_party
    ADD CONSTRAINT [PK__lr_party__3213E83F3329FD78] PRIMARY KEY (id);

CREATE INDEX [lr_party_name_idx] ON LRSAdmin.lr_party (name);
CREATE INDEX [lr_party_party_role_type_idx] ON LRSAdmin.lr_party (party_role_type);
CREATE INDEX [lr_party_party_type_idx] ON LRSAdmin.lr_party (party_type);
CREATE INDEX [lr_party_person_idx] ON LRSAdmin.lr_party (person);


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

CREATE TABLE LRSAdmin.lr_party_contact (
    [contact] numeric(19,0) NOT NULL,
    [party] numeric(19,0) NOT NULL,
    [contact_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_party_contact
    ADD CONSTRAINT [PK__lr_party__835BE61CC799B8F9] PRIMARY KEY (contact, contact_index);

CREATE INDEX [lr_party_contact__idx] ON LRSAdmin.lr_party_contact (party, contact);


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

CREATE TABLE LRSAdmin.lr_party_ext (
    [parent_id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [extended_comments] nvarchar(2000) NULL,
    [extended_params] nvarchar(1000) NULL
);

ALTER TABLE LRSAdmin.lr_party_ext
    ADD CONSTRAINT [PK__lr_party__F2A608195B937354] PRIMARY KEY (parent_id);


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

CREATE TABLE LRSAdmin.lr_party_group (
    [id] numeric(19,0) NOT NULL,
    [group_type] numeric(19,0) NOT NULL,
    [address] numeric(19,0) NULL,
    [fax] nvarchar(64) NULL,
    [email] nvarchar(64) NULL,
    [phone1_number] nvarchar(20) NULL,
    [phone1_extension] nvarchar(5) NULL,
    [phone1_type] numeric(19,0) NOT NULL,
    [phone2_number] nvarchar(20) NULL,
    [phone2_extension] nvarchar(5) NULL,
    [phone2_type] numeric(19,0) NOT NULL,
    [phone3_number] nvarchar(20) NULL,
    [phone3_extension] nvarchar(5) NULL,
    [phone3_type] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.lr_party_group
    ADD CONSTRAINT [PK__lr_party__3213E83FDE1B35C5] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_party_launit (
    [id] numeric(19,0) NOT NULL,
    [launit] numeric(19,0) NOT NULL
);

ALTER TABLE LRSAdmin.lr_party_launit
    ADD CONSTRAINT [PK__lr_party__3213E83F9B2A5181] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_party_member (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [share_nominator] int NULL,
    [share_denominator] int NULL,
    [party_ref] numeric(19,0) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [group_ref] numeric(19,0) NULL,
    [member_index] int NULL
);

ALTER TABLE LRSAdmin.lr_party_member
    ADD CONSTRAINT [PK__lr_party__3213E83F7AC1E488] PRIMARY KEY (id);

CREATE INDEX [lr_party_member__idx] ON LRSAdmin.lr_party_member (group_ref, party_ref);


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

CREATE TABLE LRSAdmin.lr_payment (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [transaction_number] nvarchar(50) NULL,
    [is_paid] tinyint NULL,
    [invoice_number] nvarchar(50) NULL,
    [receipt_number] numeric(19,0) NULL,
    [payment_type] numeric(19,0) NOT NULL,
    [payment_date] datetime NULL,
    [payment_status] numeric(19,0) NOT NULL,
    [receipt_no] nvarchar(30) NULL,
    [internal_receipt_no] nvarchar(30) NULL,
    [bank_type] numeric(19,0) NOT NULL,
    [bank_name] nvarchar(50) NULL,
    [account_name] nvarchar(50) NULL,
    [account_number] nvarchar(30) NULL,
    [paid_sum] float NULL,
    [balance_owed] float NULL,
    [penalty] float 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] nvarchar(800) NULL,
    [pm1] nvarchar(50) NULL,
    [pm2] nvarchar(50) NULL,
    [pm_dict1] numeric(19,0) NOT NULL,
    [pm_dict2] numeric(19,0) NOT NULL,
    [pm_date1] datetime NULL,
    [pm_date2] datetime NULL,
    [pm_count1] int NULL,
    [pm_count2] int NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [batch_id] numeric(19,0) NULL,
    [batch_index] int NULL
);

ALTER TABLE LRSAdmin.lr_payment
    ADD CONSTRAINT [PK__lr_payme__3213E83F6EBBDB06] PRIMARY KEY (id);

CREATE INDEX [lr_payment_payment_type_idx] ON LRSAdmin.lr_payment (payment_type);
CREATE INDEX [lr_payment_tr_number_idx] ON LRSAdmin.lr_payment (transaction_number);


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

CREATE TABLE LRSAdmin.lr_payment_transaction (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [calculated_fee] float NULL,
    [manual_fee] float NULL,
    [transaction_params] nvarchar(2000) NULL,
    [receipt_no] nvarchar(30) NULL,
    [payment_type] numeric(19,0) NOT NULL,
    [payment_date] datetime NULL,
    [bank_type] numeric(19,0) NOT NULL,
    [bank_name] nvarchar(50) NULL,
    [account_name] nvarchar(50) NULL,
    [account_number] nvarchar(30) NULL,
    [paid_sum] float NULL,
    [penalty] float NULL,
    [paid_year] int NULL,
    [pay_transaction_id] float NULL,
    [transaction_code] nvarchar(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] nvarchar(800) NULL,
    [pmt1] nvarchar(50) NULL,
    [pmt2] nvarchar(50) NULL,
    [pmt_dict1] numeric(19,0) NOT NULL,
    [pmt_dict2] numeric(19,0) NOT NULL,
    [pmt_date1] datetime NULL,
    [pmt_date2] datetime NULL,
    [pmt_count1] int NULL,
    [pmt_count2] int NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [demandnotice_number] nvarchar(12) NULL,
    [property_number] nvarchar(255) NULL,
    [payment] numeric(19,0) NULL,
    [payment_index] int NULL,
    [transaction_id] numeric(19,0) NULL,
    [transaction_index] int NULL
);

ALTER TABLE LRSAdmin.lr_payment_transaction
    ADD CONSTRAINT [PK__lr_payme__3213E83F0C01EDE0] PRIMARY KEY (id);

CREATE INDEX [lr_payment_transaction_payment_id_idx] ON LRSAdmin.lr_payment_transaction (payment);
CREATE INDEX [lr_payment_transaction_payment_type_id_idx] ON LRSAdmin.lr_payment_transaction (payment_type);
CREATE INDEX [lr_payment_transaction_transaction_id_idx] ON LRSAdmin.lr_payment_transaction (transaction_id);


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

CREATE TABLE LRSAdmin.lr_person (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [address] numeric(19,0) NULL,
    [person_type] numeric(19,0) NOT NULL,
    [person_id_type] numeric(19,0) NOT NULL,
    [person_id_number] nvarchar(64) NULL,
    [person_id_date] datetime NULL,
    [person_id_issue] nvarchar(255) NULL,
    [tin] nvarchar(50) NULL,
    [fax] nvarchar(64) NULL,
    [email] nvarchar(64) NULL,
    [phone1_number] nvarchar(20) NULL,
    [phone1_extension] nvarchar(5) NULL,
    [phone1_type] numeric(19,0) NOT NULL,
    [phone2_number] nvarchar(20) NULL,
    [phone2_extension] nvarchar(5) NULL,
    [phone2_type] numeric(19,0) NOT NULL,
    [phone3_number] nvarchar(20) NULL,
    [phone3_extension] nvarchar(5) NULL,
    [phone3_type] numeric(19,0) NOT NULL,
    [birth_date] datetime NULL,
    [pers1] nvarchar(50) NULL,
    [pers2] nvarchar(50) NULL,
    [pers_dict1] numeric(19,0) NOT NULL,
    [pers_dict2] numeric(19,0) NOT NULL,
    [pers_cost1] float NULL,
    [pers_cost2] float NULL,
    [pers_count1] int NULL,
    [pers_count2] int NULL,
    [pers_date1] datetime NULL,
    [pers_date2] datetime NULL,
    [is_submiter] tinyint NULL,
    [submiter] nvarchar(800) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [source_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_person
    ADD CONSTRAINT [PK__lr_perso__3213E83F03860C09] PRIMARY KEY (id);

CREATE INDEX [lr_person_address_idx] ON LRSAdmin.lr_person (address);
CREATE INDEX [lr_person_id_number_idx] ON LRSAdmin.lr_person (person_id_number);
CREATE INDEX [lr_person_person_type_idx] ON LRSAdmin.lr_person (person_type);


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

CREATE TABLE LRSAdmin.lr_process_event (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [event_type] numeric(19,0) NOT NULL,
    [event_date] datetime NULL,
    [description] nvarchar(800) NULL,
    [actor] nvarchar(50) NULL,
    [history] numeric(19,0) NULL,
    [event_index] int NULL
);

ALTER TABLE LRSAdmin.lr_process_event
    ADD CONSTRAINT [PK__lr_proce__3213E83F41788082] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_process_history (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [process_id] numeric(19,0) NULL,
    [process_name] nvarchar(255) NULL,
    [task_id] numeric(19,0) NULL,
    [task_name] nvarchar(255) NULL,
    [task_description] nvarchar(255) NULL,
    [task_create] datetime NULL,
    [task_complete] datetime NULL,
    [task_transition] nvarchar(255) NULL,
    [actor] nvarchar(255) NULL,
    [duration] numeric(19,0) NULL,
    [transaction_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_process_history
    ADD CONSTRAINT [PK__lr_proce__3213E83F4F3D1062] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_registry (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [code] nvarchar(32) NOT NULL,
    [description] nvarchar(255) NOT NULL,
    [lodgment_class] nvarchar(255) NOT NULL,
    [transaction_class] nvarchar(255) NOT NULL
);

ALTER TABLE LRSAdmin.lr_registry
    ADD CONSTRAINT [PK__lr_regis__3214EC07D4E590EB] PRIMARY KEY (Id);

CREATE UNIQUE INDEX [UQ__lr_regis__357D4CF92C7E14C1] ON LRSAdmin.lr_registry (code);
CREATE UNIQUE INDEX [UQ__lr_regis__489B0D977FBCB163] ON LRSAdmin.lr_registry (description);


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

CREATE TABLE LRSAdmin.lr_registry_office (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [string_code] nvarchar(10) NULL,
    [digital_code] int NULL,
    [office_name] nvarchar(100) NULL,
    [office_type] nvarchar(100) NULL,
    [address] nvarchar(255) NULL,
    [head_name] nvarchar(100) NULL,
    [phone] nvarchar(255) NULL,
    [fax] nvarchar(64) NULL,
    [email] nvarchar(64) NULL,
    [web_site] nvarchar(255) NULL,
    [main] tinyint NULL,
    [active] tinyint NULL,
    [comments] nvarchar(800) NULL
);

ALTER TABLE LRSAdmin.lr_registry_office
    ADD CONSTRAINT [PK__lr_regis__3213E83F79119EDB] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_rejection (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [rejection_date] datetime NULL,
    [comments] datetime NULL,
    [lodgment_id] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_rejection
    ADD CONSTRAINT [PK__lr_rejec__3213E83F2E2923E3] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_rejection_reason (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [reason_type] numeric(19,0) NOT NULL,
    [comments] nvarchar(2000) NULL,
    [rejection_id] numeric(19,0) NULL,
    [rejection_index] int NULL
);

ALTER TABLE LRSAdmin.lr_rejection_reason
    ADD CONSTRAINT [PK__lr_rejec__3213E83FA19DCB55] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_rental_amount_revision (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [effective_date] datetime NOT NULL,
    [annual_rental_amount] float NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [property_number] nvarchar(50) NOT NULL
);

ALTER TABLE LRSAdmin.lr_rental_amount_revision
    ADD CONSTRAINT [PK__lr_renta__3213E83F853A5855] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_replicationcontent (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [node_path] nvarchar(254) NOT NULL,
    [parent_path] nvarchar(254) NOT NULL,
    [package] numeric(19,0) NULL,
    [create_date] datetime NOT NULL
);

ALTER TABLE LRSAdmin.lr_replicationcontent
    ADD CONSTRAINT [PK__lr_repli__3213E83F576F6D6D] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_replicationlog (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [package] numeric(19,0) NULL,
    [batch_id] numeric(19,0) NOT NULL,
    [entity_id] numeric(19,0) NOT NULL,
    [entity_classname] nvarchar(128) NOT NULL,
    [logged_at] datetime NOT NULL,
    [uploaded_at] datetime NULL,
    [uploaded] tinyint NULL,
    [repeat_number] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_replicationlog
    ADD CONSTRAINT [PK__lr_repli__3213E83F9A390E42] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_replicationpackage (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [package_name] nvarchar(128) NOT NULL,
    [status] numeric(19,0) NOT NULL,
    [modify_date] datetime NOT NULL,
    [create_date] datetime NOT NULL
);

ALTER TABLE LRSAdmin.lr_replicationpackage
    ADD CONSTRAINT [PK__lr_repli__3213E83F0096348A] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_rrr (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [rrr_type] numeric(19,0) NOT NULL,
    [transaction_source] nvarchar(50) NULL,
    [transaction_cancel] nvarchar(50) NULL,
    [share_nominator] int NULL,
    [share_denominator] int NULL,
    [description] nvarchar(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] nvarchar(100) NULL,
    [condition_approved_on] datetime NULL,
    [right1] nvarchar(50) NULL,
    [right2] nvarchar(50) NULL,
    [party] numeric(19,0) NULL,
    [la_unit] numeric(19,0) NULL,
    [create_date] datetime NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [source_id] numeric(19,0) NULL,
    [pay_period_year] int NULL,
    [term_day] int NULL,
    [consideration] float NULL,
    [consideration_currency] numeric(19,0) NULL,
    [rental_amount] float NULL,
    [build_value] float NULL,
    [improvement_amount_currency] numeric(19,0) NULL,
    [build_term] int NULL,
    [security_number_1] nvarchar(255) NULL,
    [security_number_2] nvarchar(255) NULL
);

ALTER TABLE LRSAdmin.lr_rrr
    ADD CONSTRAINT [PK__lr_rrr__3213E83FECCA5743] PRIMARY KEY (id);

CREATE INDEX [lr_rrr__idx] ON LRSAdmin.lr_rrr (party, la_unit);
CREATE INDEX [lr_rrr_rrr_type_idx] ON LRSAdmin.lr_rrr (rrr_type);


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

CREATE TABLE LRSAdmin.lr_rrr_billing (
    [rrr] numeric(19,0) NOT NULL,
    [billing] numeric(19,0) NOT NULL,
    [rrr_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_rrr_billing
    ADD CONSTRAINT [PK__lr_rrr_b__C4D9FF94CD9E1150] PRIMARY KEY (rrr, rrr_index);


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

CREATE TABLE LRSAdmin.lr_rrr_condition (
    [rrr] numeric(19,0) NOT NULL,
    [condition] numeric(19,0) NOT NULL,
    [rrr_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_rrr_condition
    ADD CONSTRAINT [PK__lr_rrr_c__C4D9FF94E4A188D9] PRIMARY KEY (rrr, rrr_index);


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

CREATE TABLE LRSAdmin.lr_rrr_deleted (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [rrr_type] numeric(19,0) NOT NULL,
    [transaction_source] nvarchar(50) NULL,
    [transaction_cancel] nvarchar(50) NULL,
    [share_nominator] int NULL,
    [share_denominator] int NULL,
    [description] nvarchar(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] nvarchar(100) NULL,
    [condition_approved_on] datetime NULL,
    [right1] nvarchar(50) NULL,
    [right2] nvarchar(50) NULL,
    [party] numeric(19,0) NULL,
    [la_unit] numeric(19,0) NULL,
    [create_date] datetime NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [source_id] numeric(19,0) NULL,
    [pay_period_year] int NULL,
    [term_day] int NULL,
    [consideration] float NULL,
    [consideration_currency] numeric(19,0) NULL,
    [rental_amount] float NULL,
    [build_value] float NULL,
    [improvement_amount_currency] numeric(19,0) NULL,
    [build_term] int NULL,
    [security_number_1] nvarchar(255) NULL,
    [security_number_2] nvarchar(255) NULL
);


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

CREATE TABLE LRSAdmin.lr_rrr_metadata (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [code] nvarchar(64) NOT NULL,
    [label] nvarchar(254) NOT NULL,
    [descr] nvarchar(1000) NULL,
    [category] nvarchar(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] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_rrr_metadata
    ADD CONSTRAINT [PK__lr_rrr_m__3214EC077B723980] PRIMARY KEY (Id);

CREATE UNIQUE INDEX [UQ__lr_rrr_m__357D4CF9E0D16904] ON LRSAdmin.lr_rrr_metadata (code);


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

CREATE TABLE LRSAdmin.lr_rrr_patched (
    [id] numeric(19,0) NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [rrr_type] numeric(19,0) NOT NULL,
    [transaction_source] nvarchar(50) NULL,
    [transaction_cancel] nvarchar(50) NULL,
    [share_nominator] int NULL,
    [share_denominator] int NULL,
    [description] nvarchar(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] nvarchar(100) NULL,
    [condition_approved_on] datetime NULL,
    [right1] nvarchar(50) NULL,
    [right2] nvarchar(50) NULL,
    [party] numeric(19,0) NOT NULL,
    [la_unit] numeric(19,0) NULL,
    [create_date] datetime NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [source_id] numeric(19,0) NULL,
    [pay_period_year] int NULL,
    [term_day] int NULL,
    [consideration] float NULL,
    [rental_amount] float NULL,
    [build_value] float NULL,
    [build_term] int NULL,
    [security_number_1] nvarchar(255) NULL,
    [security_number_2] nvarchar(255) NULL,
    [consideration_currency] numeric(19,0) NULL,
    [improvement_amount_currency] numeric(19,0) NULL
);


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

CREATE TABLE LRSAdmin.lr_setting (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [category] nvarchar(64) NOT NULL,
    [name] nvarchar(150) NOT NULL,
    [value] nvarchar(1000) NOT NULL,
    [description] nvarchar(1000) NULL
);

ALTER TABLE LRSAdmin.lr_setting
    ADD CONSTRAINT [PK__lr_setti__3214EC07F68F69A0] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_simplecounter (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [counter] nvarchar(255) NOT NULL,
    [value] numeric(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] nvarchar(5) NULL,
    [reset_new_year] tinyint NULL,
    [advance_config] nvarchar(255) NULL
);

ALTER TABLE LRSAdmin.lr_simplecounter
    ADD CONSTRAINT [PK__lr_simpl__3214EC078A8550AE] PRIMARY KEY (Id);

CREATE UNIQUE INDEX [UQ__lr_simpl__28352C07C570BBE6] ON LRSAdmin.lr_simplecounter (counter);


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

CREATE TABLE LRSAdmin.lr_simplecounter_pool (
    [Id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [counter] nvarchar(255) NOT NULL,
    [value] numeric(19,0) NOT NULL,
    [ref_number] nvarchar(255) NULL,
    [modify_date] datetime NULL
);

ALTER TABLE LRSAdmin.lr_simplecounter_pool
    ADD CONSTRAINT [PK__lr_simpl__3214EC0700F26B99] PRIMARY KEY (Id);


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

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

ALTER TABLE LRSAdmin.lr_site_analysis
    ADD CONSTRAINT [PK__lr_site___3214EC075F13B6D1] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_source_document (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [document_number] nvarchar(50) NULL,
    [ref_number] nvarchar(50) NULL,
    [minute_number] nvarchar(50) NULL,
    [document_type] numeric(19,0) NOT NULL,
    [duplicate] tinyint NULL,
    [access_type] numeric(19,0) NOT NULL,
    [acceptance] datetime NULL,
    [recordation] datetime NULL,
    [submission] datetime NULL,
    [issued_by] nvarchar(500) NULL,
    [page_count] int NULL,
    [comments] nvarchar(800) NULL,
    [create_date] datetime NULL,
    [modified_at] datetime NULL,
    [modified_by] nvarchar(255) NULL,
    [property_file_page] nvarchar(50) NULL,
    [sdoc1] nvarchar(50) NULL,
    [sdoc2] nvarchar(50) NULL,
    [sdoc_dict1] numeric(19,0) NOT NULL,
    [sdoc_dict2] numeric(19,0) NOT NULL,
    [sdoc_count1] int NULL,
    [sdoc_count2] int NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_source_document
    ADD CONSTRAINT [PK__lr_sourc__3213E83F7D90E968] PRIMARY KEY (id);

CREATE INDEX [lr_source_document_document_number_idx] ON LRSAdmin.lr_source_document (document_number);
CREATE INDEX [lr_source_document_document_type_idx] ON LRSAdmin.lr_source_document (document_type);


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

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

ALTER TABLE LRSAdmin.lr_spatial_unit
    ADD CONSTRAINT [PK__lr_spati__3213E83F35C30A89] PRIMARY KEY (id);

CREATE INDEX [lr_spatial_unit_address_idx] ON LRSAdmin.lr_spatial_unit (address);
CREATE INDEX [lr_spatial_unit_old_property_id_idx] ON LRSAdmin.lr_spatial_unit (old_property_id);
CREATE INDEX [lr_spatial_unit_plannumber_idx] ON LRSAdmin.lr_spatial_unit (plan_number);
CREATE INDEX [lr_spatial_unit_suid_idx] ON LRSAdmin.lr_spatial_unit (suid);


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

CREATE TABLE LRSAdmin.lr_spatial_unit_ext (
    [parent_id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [extended_comments] nvarchar(2000) NULL,
    [extended_params] nvarchar(1000) NULL
);

ALTER TABLE LRSAdmin.lr_spatial_unit_ext
    ADD CONSTRAINT [PK__lr_spati__F2A60819CC81EBFB] PRIMARY KEY (parent_id);


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

CREATE TABLE LRSAdmin.lr_spatial_unit_member (
    [parent_unit] numeric(19,0) NOT NULL,
    [child_unit] numeric(19,0) NOT NULL,
    [unit_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_spatial_unit_member
    ADD CONSTRAINT [PK__lr_spati__F489AF29F303A653] PRIMARY KEY (parent_unit, unit_index);

CREATE INDEX [lr_spatial_unit_member__idx] ON LRSAdmin.lr_spatial_unit_member (parent_unit, child_unit);


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

CREATE TABLE LRSAdmin.lr_survey_plan (
    [Id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [plan_number] nvarchar(40) NULL,
    [local_government_area] numeric(19,0) NULL,
    [zone] numeric(19,0) NOT NULL,
    [layout] numeric(19,0) NOT NULL,
    [city] nvarchar(100) NULL,
    [cell] nvarchar(100) NULL,
    [ward] nvarchar(100) NULL,
    [district_text] nvarchar(100) NULL,
    [region] numeric(19,0) NOT NULL,
    [country] numeric(19,0) NOT NULL,
    [surveyor_plan_no] nvarchar(50) NULL,
    [area] float NULL,
    [area_unit_type] numeric(19,0) NOT NULL,
    [survey_start_date] datetime NULL,
    [survey_end_date] datetime NULL,
    [surveyor_name] nvarchar(32) NULL,
    [tracing_number] nvarchar(32) NULL,
    [approval_date] datetime NULL,
    [survey_type] numeric(19,0) NOT NULL,
    [plots_Amount] int NOT NULL,
    [terrain_type] numeric(19,0) NOT NULL,
    [beacon_amount_re_establish] int NOT NULL,
    [beacon_amount_perimeter] int NOT NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [surveyor_type] numeric(19,0) NOT NULL,
    [comments] nvarchar(2000) NULL
);

ALTER TABLE LRSAdmin.lr_survey_plan
    ADD CONSTRAINT [PK__lr_surve__3214EC07D81925DA] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_taxation (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [tax_amount] float NULL,
    [tax_type] numeric(19,0) NOT NULL,
    [tax_date] datetime NULL,
    [comments] nvarchar(800) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_taxation
    ADD CONSTRAINT [PK__lr_taxat__3213E83FDDF6B317] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_tempcounter (
    [Id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [counter] numeric(19,0) NOT NULL,
    [value_text] nvarchar(255) NOT NULL,
    [ref_number] nvarchar(255) NULL,
    [transaction_id] numeric(19,0) NULL,
    [transaction_index] int NULL
);

ALTER TABLE LRSAdmin.lr_tempcounter
    ADD CONSTRAINT [PK__lr_tempc__3214EC076C6DB7D3] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_transaction (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [transaction_number] nvarchar(50) NULL,
    [transaction_type] numeric(19,0) NULL,
    [transaction_status] numeric(19,0) NOT NULL,
    [transaction_source] numeric(19,0) NOT NULL,
    [source_property_ids] nvarchar(500) NULL,
    [target_property_ids] nvarchar(500) NULL,
    [old_property_id] nvarchar(50) NULL,
    [parent_property_ids] nvarchar(500) NULL,
    [tenure_type] numeric(19,0) NOT NULL,
    [is_search_oldfile] tinyint NULL,
    [registration_fee] float NULL,
    [consideration] float NULL,
    [interest_money] float 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] float NULL,
    [partial] tinyint NULL,
    [pageNumber] nvarchar(16) NULL,
    [cert_nos] nvarchar(255) NULL,
    [term_year] int NULL,
    [term_month] int NULL,
    [term_year_ext] int NULL,
    [term_month_ext] int NULL,
    [lease_extension] numeric(19,0) NOT NULL,
    [lease_duration] numeric(19,0) NOT NULL,
    [duration] int NULL,
    [build_term] int NULL,
    [build_value] float NULL,
    [pay_period_year] int NULL,
    [pay_period_month] int NULL,
    [volume] nvarchar(20) NULL,
    [folio] nvarchar(20) NULL,
    [volume_linked] nvarchar(20) NULL,
    [folio_linked] nvarchar(20) NULL,
    [recordingno] nvarchar(30) NULL,
    [internal_receipt_no] nvarchar(30) NULL,
    [serial_number] nvarchar(30) NULL,
    [general_number] nvarchar(50) NULL,
    [related_number] nvarchar(50) NULL,
    [related_page_number] nvarchar(50) NULL,
    [related_volume] nvarchar(50) NULL,
    [deed_case] numeric(19,0) NOT NULL,
    [related_instr_number] nvarchar(50) NULL,
    [lodgment_number] nvarchar(50) NULL,
    [boxno] nvarchar(20) NULL,
    [special_condition] nvarchar(50) NULL,
    [inscription] nvarchar(800) NULL,
    [inscription2] nvarchar(800) NULL,
    [reg_initials] nvarchar(20) NULL,
    [blockplot] nvarchar(200) NULL,
    [volumefolio] nvarchar(150) NULL,
    [filetype] numeric(19,0) NOT NULL,
    [region] numeric(19,0) NOT NULL,
    [district] numeric(19,0) NOT NULL,
    [is_delivered] tinyint NULL,
    [is_right_required] tinyint NULL,
    [is_inactive] tinyint NULL,
    [is_mem_transaction] tinyint NULL,
    [comments] nvarchar(800) NULL,
    [site_analysis] nvarchar(800) NULL,
    [inspection_officer] nvarchar(50) NULL,
    [gis_params] nvarchar(800) NULL,
    [tran1] nvarchar(50) NULL,
    [tran2] nvarchar(50) NULL,
    [tran_date1] datetime NULL,
    [tran_date2] datetime NULL,
    [tran_dict1] numeric(19,0) NOT NULL,
    [tran_dict2] numeric(19,0) NOT NULL,
    [tran_cost1] float NULL,
    [tran_cost2] float NULL,
    [tran_count1] int NULL,
    [tran_count2] int NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL,
    [demandnotice_number] nvarchar(12) NULL,
    [batch] numeric(19,0) NULL,
    [transaction_index] int NULL,
    [term_day] int NULL,
    [consideration_currency] numeric(19,0) NULL,
    [temp_consideration] nvarchar(30) NULL,
    [improvement_amount_currency] numeric(19,0) NULL,
    [data_corrected_transaction_number] nvarchar(50) NULL,
    [data_corrected_transaction_type] numeric(19,0) NULL,
    [data_corrected_comments] nvarchar(800) NULL,
    [data_corrected_create_date] datetime NULL,
    [data_corrected_complete_date] datetime NULL,
    [recommendation_memorandum] nvarchar(800) NULL,
    [SurveyPlan] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_transaction
    ADD CONSTRAINT [PK__lr_trans__3213E83F7F929339] PRIMARY KEY (id);

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


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

CREATE TABLE LRSAdmin.lr_transaction_document (
    [transaction_id] numeric(19,0) NOT NULL,
    [document_id] numeric(19,0) NOT NULL,
    [document_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_transaction_document
    ADD CONSTRAINT [PK__lr_trans__37C7C1175599DCBD] PRIMARY KEY (transaction_id, document_index);

CREATE INDEX [lr_transaction_document__idx] ON LRSAdmin.lr_transaction_document (transaction_id, document_id);


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

CREATE TABLE LRSAdmin.lr_transaction_ext (
    [parent_id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [extended_comments] nvarchar(2000) NULL,
    [extended_params] nvarchar(1000) NULL,
    [NonExistingPropertiesSearch] nvarchar(1000) NULL,
    [CountPropertiesSearch] numeric(19,0) NULL
);

ALTER TABLE LRSAdmin.lr_transaction_ext
    ADD CONSTRAINT [PK__lr_trans__F2A60819F2BCC067] PRIMARY KEY (parent_id);


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

CREATE TABLE LRSAdmin.lr_transaction_launit (
    [transaction_id] numeric(19,0) NOT NULL,
    [launit_id] numeric(19,0) NOT NULL,
    [launit_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_transaction_launit
    ADD CONSTRAINT [PK__lr_trans__622533F643A3D029] PRIMARY KEY (transaction_id, launit_index);

CREATE INDEX [lr_transaction_launit__idx] ON LRSAdmin.lr_transaction_launit (transaction_id, launit_id);


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

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

ALTER TABLE LRSAdmin.lr_transaction_metadata
    ADD CONSTRAINT [PK__lr_trans__3214EC07486BD5FA] PRIMARY KEY (Id);


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

CREATE TABLE LRSAdmin.lr_transaction_note (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [note_type] numeric(19,0) NOT NULL,
    [comments] nvarchar(800) NULL,
    [user_name] nvarchar(150) NULL,
    [task_id] numeric(19,0) NULL,
    [task_name] nvarchar(250) NULL,
    [comment_ref] nvarchar(250) NULL,
    [create_date] datetime NULL,
    [transaction_id] numeric(19,0) NULL,
    [note_index] int NULL
);

ALTER TABLE LRSAdmin.lr_transaction_note
    ADD CONSTRAINT [PK__lr_trans__3213E83F3C36B050] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_transaction_party (
    [transaction_id] numeric(19,0) NOT NULL,
    [party_id] numeric(19,0) NOT NULL,
    [party_index] int NOT NULL
);

ALTER TABLE LRSAdmin.lr_transaction_party
    ADD CONSTRAINT [PK__lr_trans__6437D215911BAEDB] PRIMARY KEY (transaction_id, party_index);

CREATE INDEX [lr_transaction_party__idx] ON LRSAdmin.lr_transaction_party (transaction_id, party_id);


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

CREATE TABLE LRSAdmin.lr_transaction_record (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [operation_type] numeric(19,0) NOT NULL,
    [source_rrr] numeric(19,0) NULL,
    [target_rrr] numeric(19,0) NULL,
    [transaction_id] numeric(19,0) NULL,
    [record_index] int NULL
);

ALTER TABLE LRSAdmin.lr_transaction_record
    ADD CONSTRAINT [PK__lr_trans__3213E83FF6B9CD01] PRIMARY KEY (id);

CREATE INDEX [lr_transaction_record_operation_type_idx] ON LRSAdmin.lr_transaction_record (operation_type);
CREATE INDEX [lr_transaction_record_transaction_id_idx] ON LRSAdmin.lr_transaction_record (transaction_id);


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

CREATE TABLE LRSAdmin.lr_usage (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [usage_type] numeric(19,0) NOT NULL,
    [comments] nvarchar(800) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_usage
    ADD CONSTRAINT [PK__lr_usage__3213E83FB9970F7B] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.lr_valuation (
    [id] numeric(19,0) NOT NULL,
    [Hjtype] nvarchar(255) NOT NULL,
    [value] float NULL,
    [value_type] numeric(19,0) NOT NULL,
    [value_date] datetime NULL,
    [comments] nvarchar(800) NULL,
    [valu1] nvarchar(50) NULL,
    [valu2] nvarchar(50) NULL,
    [valu_dict1] numeric(19,0) NOT NULL,
    [valu_dict2] numeric(19,0) NOT NULL,
    [valu_date1] datetime NULL,
    [valu_date2] datetime NULL,
    [valu_count1] int NULL,
    [valu_count2] int NULL,
    [suid] nvarchar(50) NULL,
    [transaction_number] nvarchar(50) NULL,
    [version] numeric(19,0) NULL,
    [begin_lifespan_version] datetime NULL,
    [end_lifespan_version] datetime NULL
);

ALTER TABLE LRSAdmin.lr_valuation
    ADD CONSTRAINT [PK__lr_valua__3213E83F1BD1D608] PRIMARY KEY (id);


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

CREATE TABLE LRSAdmin.sdms_bootstrap (
    [id] numeric(19,0) IDENTITY(1,1) NOT NULL,
    [resource_name] nvarchar(255) NOT NULL,
    [res_version] int NOT NULL,
    [created] datetime NOT NULL,
    [modified] datetime NOT NULL,
    [is_model] tinyint NOT NULL,
    [resource_type] nvarchar(255) NULL
);

ALTER TABLE LRSAdmin.sdms_bootstrap
    ADD CONSTRAINT [PK__sdms_boo__3213E83F05EE9B6B] PRIMARY KEY (id);


