mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V3.4 to HEAD (SQL-level fixes)
23368: Merged V3.3-BUG-FIX to V3.4 23363: Merged V3.3 to V3.3-BUG-FIX 23358: (RECORD ONLY) Removed redundant svn:mergeinfo 23359: Minor I18N fix on patch.updateMimetypes2 23360: Fixed ALF-3167: Websphere/Db2 SchemaBootstrap.dumpSchema is failing due to result set is closed error - SchemaDump uses nested resultset reads, which is incompatible with SchemaBootstrap's auto-commit connection - Also pull back some changes to fix MySQL builds after MySQL upgrades 23361: More patch I18N 23362: Merged V3.2 to V3.3 23333: Fixed ALF-5396: Missing FK indexes on non-MySQL databases 23324: Fixed ALF-5396: Missing FK indexes on non-MySQL databases - Create scripts were manually ported and required full clean-install testing in addition to upgrade testing 23372: Fixed ALF-5421: update_ChildAssocsIndex ibatis statement does not include child_node_id 23523: Merged BRANCHES/DEV/V3.3-BUG-FIX to BRANCHES/V3.4: 23490: Merged BRANCHES/V3.3 to BRANCHES/DEV/V3.3-BUG-FIX: 23470: Merged V3.2 to V3.3 23395: Merged BRANCHES/DEV/BELARUS/HEAD_2010_09_21 to V32 22821: ALF-4203: WCM 2.2.7 case-sensitivity causes errors after upgrade to 3.2.x. 23055: ALF-4203: WCM 2.2.7 case-sensitivity causes errors after upgrade to 3.2.x (record-only, used only part of this checkin). 23198: ALF-4203: WCM 2.2.7 case-sensitivity causes errors after upgrade to 3.2.x. 23398: ALF-4203: fix for "WCM 2.2.7 case-senstivity causes err rs after upgrade to 3.2.x" - updated template for patch.eliminateDuplicates 23433: Fix for ALF-4203: "WCM 2.2.7 case-sensitivity causes errors after upgrade to 3.2.x" - revised fix 23752: Fixed ALF-5453: Remove old Audit tables from schema create scripts 23957: Fixed ALF-5308: SQL error when changing name for record / folder with dispostion schedule applied 24250: Fix typo in original fix of ALF-5308 and add unit test 24345: Merged V3.3 to V3.4 24337: Fixed ALF-6078: WCM: alf_lock table version number fails during roll-over. - Added specific, minor fixes for 3.4 24352: Fix SQL fallout from ALF-6078 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@24354 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -45,6 +45,9 @@
|
||||
|
||||
<!-- ensure that the schema is bootstrapped -->
|
||||
<bean id="schemaBootstrap" class="org.alfresco.repo.domain.schema.SchemaBootstrap" >
|
||||
<property name="dataSource">
|
||||
<ref bean="dataSource"/>
|
||||
</property>
|
||||
<property name="localSessionFactory">
|
||||
<ref bean="&sessionFactory"></ref> <!-- inject the actual factory, not a session -->
|
||||
</property>
|
||||
@@ -110,6 +113,7 @@
|
||||
<ref bean="patch.db-V3.2-Child-Assoc-QName-CRC" />
|
||||
<ref bean="patch.db-V3.3-modify-index-permission_id" />
|
||||
<ref bean="patch.db-V3.2-AddFKIndexes" />
|
||||
<ref bean="patch.db-V3.2-AddFKIndexes-2" />
|
||||
<ref bean="patch.db-V3.4-UsageTables" />
|
||||
<ref bean="patch.db-V3.0-ActivityTables" />
|
||||
</list>
|
||||
@@ -117,7 +121,6 @@
|
||||
<property name="postUpdateScriptPatches">
|
||||
<list>
|
||||
<ref bean="patch.db-V2.1-RemoveWcmSubmittedAspect" />
|
||||
<ref bean="patch.db-V2.1-AuditPathIndex" />
|
||||
<ref bean="patch.db-V3.1-Allow-IPv6" />
|
||||
<ref bean="patch.db-V3.2-Remove-AVM-Issuer" />
|
||||
<ref bean="patch.db-V3.2-Modify-AVM-MimeType" />
|
||||
|
@@ -153,90 +153,6 @@ CREATE TABLE alf_authority_alias
|
||||
CONSTRAINT fk_alf_autha_ali FOREIGN KEY (alias_id) REFERENCES alf_authority (id)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE alf_audit_config
|
||||
(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
config_url TEXT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE alf_audit_date
|
||||
(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
date_only date NOT NULL,
|
||||
day_of_year INTEGER NOT NULL,
|
||||
day_of_month INTEGER NOT NULL,
|
||||
day_of_week INTEGER NOT NULL,
|
||||
week_of_year INTEGER NOT NULL,
|
||||
week_of_month INTEGER NOT NULL,
|
||||
month INTEGER NOT NULL,
|
||||
quarter INTEGER NOT NULL,
|
||||
half_year INTEGER NOT NULL,
|
||||
full_year INTEGER NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_alf_adtd_woy (week_of_year),
|
||||
KEY idx_alf_adtd_fy (full_year),
|
||||
KEY idx_alf_adtd_q (quarter),
|
||||
KEY idx_alf_adtd_wom (week_of_month),
|
||||
KEY idx_alf_adtd_dom (day_of_month),
|
||||
KEY idx_alf_adtd_doy (day_of_year),
|
||||
KEY idx_alf_adtd_dow (day_of_week),
|
||||
KEY idx_alf_adtd_m (month),
|
||||
KEY idx_alf_adtd_hy (half_year),
|
||||
KEY idx_alf_adtd_dat (date_only)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE alf_audit_source
|
||||
(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
application VARCHAR(255) NOT NULL,
|
||||
service VARCHAR(255),
|
||||
method VARCHAR(255),
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_alf_adts_met (method),
|
||||
KEY idx_alf_adts_ser (service),
|
||||
KEY idx_alf_adts_app (application)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE alf_audit_fact
|
||||
(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
user_id VARCHAR(255) NOT NULL,
|
||||
timestamp DATETIME NOT NULL,
|
||||
transaction_id VARCHAR(56) NOT NULL,
|
||||
session_id VARCHAR(56),
|
||||
store_protocol VARCHAR(50),
|
||||
store_id VARCHAR(100),
|
||||
node_uuid VARCHAR(36),
|
||||
path TEXT,
|
||||
filtered BIT NOT NULL,
|
||||
return_val TEXT,
|
||||
arg_1 TEXT,
|
||||
arg_2 TEXT,
|
||||
arg_3 TEXT,
|
||||
arg_4 TEXT,
|
||||
arg_5 TEXT,
|
||||
fail BIT NOT NULL,
|
||||
serialized_url TEXT,
|
||||
exception_message TEXT,
|
||||
host_address TEXT,
|
||||
client_address TEXT,
|
||||
message_text TEXT,
|
||||
audit_date_id BIGINT NOT NULL,
|
||||
audit_conf_id BIGINT NOT NULL,
|
||||
audit_source_id BIGINT NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_alf_adtf_ref (store_protocol, store_id, node_uuid),
|
||||
KEY idx_alf_adtf_usr (user_id),
|
||||
KEY fk_alf_adtf_src (audit_source_id),
|
||||
KEY fk_alf_adtf_date (audit_date_id),
|
||||
KEY fk_alf_adtf_conf (audit_conf_id),
|
||||
KEY idx_alf_adtf_pth (path(128)),
|
||||
CONSTRAINT fk_alf_adtf_conf FOREIGN KEY (audit_conf_id) REFERENCES alf_audit_config (id),
|
||||
CONSTRAINT fk_alf_adtf_date FOREIGN KEY (audit_date_id) REFERENCES alf_audit_date (id),
|
||||
CONSTRAINT fk_alf_adtf_src FOREIGN KEY (audit_source_id) REFERENCES alf_audit_source (id)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE alf_server
|
||||
(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
CREATE SEQUENCE alf_activity_feed_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_activity_feed
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -27,8 +28,8 @@ CREATE INDEX feed_postuserid_idx ON alf_activity_feed (post_user_id);
|
||||
CREATE INDEX feed_feeduserid_idx ON alf_activity_feed (feed_user_id);
|
||||
CREATE INDEX feed_sitenetwork_idx ON alf_activity_feed (site_network);
|
||||
CREATE INDEX feed_activityformat_idx ON alf_activity_feed (activity_format);
|
||||
CREATE SEQUENCE alf_activity_feed_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_activity_feed_control_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_activity_feed_control
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -39,8 +40,8 @@ CREATE TABLE alf_activity_feed_control
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX feedctrl_feeduserid_idx ON alf_activity_feed_control (feed_user_id);
|
||||
CREATE SEQUENCE alf_activity_feed_control_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_activity_post_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_activity_post
|
||||
(
|
||||
sequence_id INT8 NOT NULL,
|
||||
@@ -57,7 +58,6 @@ CREATE TABLE alf_activity_post
|
||||
);
|
||||
CREATE INDEX post_jobtasknode_idx ON alf_activity_post (job_task_node);
|
||||
CREATE INDEX post_status_idx ON alf_activity_post (status);
|
||||
CREATE SEQUENCE alf_activity_post_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
|
||||
--
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
CREATE SEQUENCE alf_audit_model_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_audit_model
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -16,9 +17,9 @@ CREATE TABLE alf_audit_model
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_alf_aud_mod_cr ON alf_audit_model(content_crc);
|
||||
CREATE INDEX fk_alf_aud_mod_cd ON alf_audit_model(content_data_id);
|
||||
|
||||
CREATE SEQUENCE alf_audit_model_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_audit_app_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_audit_app
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -31,8 +32,10 @@ CREATE TABLE alf_audit_app
|
||||
CONSTRAINT fk_alf_aud_app_dis FOREIGN KEY (disabled_paths_id) REFERENCES alf_prop_root (id),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_audit_app_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE INDEX fk_alf_aud_app_mod ON alf_audit_app(audit_model_id);
|
||||
CREATE INDEX fk_alf_aud_app_dis ON alf_audit_app(disabled_paths_id);
|
||||
|
||||
CREATE SEQUENCE alf_audit_entry_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_audit_entry
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -46,8 +49,9 @@ CREATE TABLE alf_audit_entry
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX idx_alf_aud_ent_tm ON alf_audit_entry(audit_time);
|
||||
|
||||
CREATE SEQUENCE alf_audit_entry_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE INDEX fk_alf_aud_ent_app ON alf_audit_entry(audit_app_id);
|
||||
CREATE INDEX fk_alf_aud_ent_use ON alf_audit_entry(audit_user_id);
|
||||
CREATE INDEX fk_alf_aud_ent_pro ON alf_audit_entry(audit_values_id);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
|
@@ -47,6 +47,7 @@
|
||||
primary key (node_id, qname_id)
|
||||
);
|
||||
|
||||
create sequence avm_nodes_seq start with 1 increment by 1;
|
||||
create table avm_nodes (
|
||||
id INT8 not null,
|
||||
class_type varchar(20) not null,
|
||||
@@ -75,8 +76,7 @@
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create sequence avm_nodes_seq start with 1 increment by 1;
|
||||
|
||||
create sequence avm_store_properties_seq start with 1 increment by 1;
|
||||
create table avm_store_properties (
|
||||
id INT8 not null,
|
||||
avm_store_id INT8,
|
||||
@@ -93,8 +93,7 @@
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create sequence avm_store_properties_seq start with 1 increment by 1;
|
||||
|
||||
create sequence avm_stores_seq start with 1 increment by 1;
|
||||
create table avm_stores (
|
||||
id INT8 not null,
|
||||
vers INT8 not null,
|
||||
@@ -105,8 +104,6 @@
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create sequence avm_stores_seq start with 1 increment by 1;
|
||||
|
||||
create table avm_version_layered_node_entry (
|
||||
version_root_id INT8 not null,
|
||||
md5sum varchar(32) not null,
|
||||
@@ -114,6 +111,7 @@
|
||||
primary key (version_root_id, md5sum)
|
||||
);
|
||||
|
||||
create sequence avm_version_roots_seq start with 1 increment by 1;
|
||||
create table avm_version_roots (
|
||||
id INT8 not null,
|
||||
version_id INT4 not null,
|
||||
@@ -127,8 +125,6 @@
|
||||
unique (version_id, avm_store_id)
|
||||
);
|
||||
|
||||
create sequence avm_version_roots_seq start with 1 increment by 1;
|
||||
|
||||
alter table avm_aspects
|
||||
add constraint fk_avm_nasp_n
|
||||
foreign key (node_id)
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
CREATE SEQUENCE alf_mimetype_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_mimetype
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -15,8 +16,8 @@ CREATE TABLE alf_mimetype
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (mimetype_str)
|
||||
);
|
||||
CREATE SEQUENCE alf_mimetype_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_encoding_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_encoding
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -25,11 +26,11 @@ CREATE TABLE alf_encoding
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (encoding_str)
|
||||
);
|
||||
CREATE SEQUENCE alf_encoding_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
-- This table may exist during upgrades, but must be removed.
|
||||
-- The drop statement is therefore optional.
|
||||
DROP TABLE alf_content_url; --(optional)
|
||||
CREATE SEQUENCE alf_content_url_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_content_url
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -42,8 +43,8 @@ CREATE TABLE alf_content_url
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_alf_conturl_cr ON alf_content_url (content_url_short, content_url_crc);
|
||||
CREATE INDEX idx_alf_conturl_ot ON alf_content_url (orphan_time);
|
||||
CREATE SEQUENCE alf_content_url_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_content_data_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_content_data
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -58,7 +59,10 @@ CREATE TABLE alf_content_data
|
||||
CONSTRAINT fk_alf_cont_loc FOREIGN KEY (content_locale_id) REFERENCES alf_locale (id),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_content_data_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE INDEX fk_alf_cont_url ON alf_content_data (content_url_id);
|
||||
CREATE INDEX fk_alf_cont_mim ON alf_content_data (content_mimetype_id);
|
||||
CREATE INDEX fk_alf_cont_enc ON alf_content_data (content_encoding_id);
|
||||
CREATE INDEX fk_alf_cont_loc ON alf_content_data (content_locale_id);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
CREATE SEQUENCE alf_lock_resource_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_lock_resource
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -18,8 +19,7 @@ CREATE TABLE alf_lock_resource
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_alf_lockr_key ON alf_lock_resource (qname_ns_id, qname_localname);
|
||||
|
||||
CREATE SEQUENCE alf_lock_resource_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_lock_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_lock
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -34,8 +34,8 @@ CREATE TABLE alf_lock
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_alf_lock_key ON alf_lock (shared_resource_id, excl_resource_id);
|
||||
CREATE INDEX fk_alf_lock_excl ON alf_lock (excl_resource_id);
|
||||
|
||||
CREATE SEQUENCE alf_lock_seq START WITH 1 INCREMENT BY 1;
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
CREATE SEQUENCE alf_prop_class_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_class
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -18,8 +19,6 @@ CREATE TABLE alf_prop_class
|
||||
CREATE UNIQUE INDEX idx_alf_propc_crc ON alf_prop_class(java_class_name_crc, java_class_name_short);
|
||||
CREATE INDEX idx_alf_propc_clas ON alf_prop_class(java_class_name);
|
||||
|
||||
CREATE SEQUENCE alf_prop_class_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_prop_date_value
|
||||
(
|
||||
date_value INT8 NOT NULL,
|
||||
@@ -36,6 +35,7 @@ CREATE TABLE alf_prop_date_value
|
||||
);
|
||||
CREATE INDEX idx_alf_propdt_dt ON alf_prop_date_value(full_year, month_of_year, day_of_month);
|
||||
|
||||
CREATE SEQUENCE alf_prop_double_value_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_double_value
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -44,9 +44,8 @@ CREATE TABLE alf_prop_double_value
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_alf_propd_val ON alf_prop_double_value(double_value);
|
||||
|
||||
CREATE SEQUENCE alf_prop_double_value_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
-- Stores unique, case-sensitive string values --
|
||||
CREATE SEQUENCE alf_prop_string_value_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_string_value
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -58,16 +57,15 @@ CREATE TABLE alf_prop_string_value
|
||||
CREATE INDEX idx_alf_props_str ON alf_prop_string_value(string_value);
|
||||
CREATE UNIQUE INDEX idx_alf_props_crc ON alf_prop_string_value(string_end_lower, string_crc);
|
||||
|
||||
CREATE SEQUENCE alf_prop_string_value_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_prop_serializable_value_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_serializable_value
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
serializable_value BYTEA NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_prop_serializable_value_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_prop_value_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_value
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -79,15 +77,13 @@ CREATE TABLE alf_prop_value
|
||||
CREATE INDEX idx_alf_propv_per ON alf_prop_value(persisted_type, long_value);
|
||||
CREATE UNIQUE INDEX idx_alf_propv_act ON alf_prop_value(actual_type_id, long_value);
|
||||
|
||||
CREATE SEQUENCE alf_prop_value_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_prop_root_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_root
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
version INT4 NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_prop_root_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_prop_link
|
||||
(
|
||||
@@ -102,7 +98,10 @@ CREATE TABLE alf_prop_link
|
||||
PRIMARY KEY (root_prop_id, contained_in, prop_index)
|
||||
);
|
||||
CREATE INDEX idx_alf_propln_for ON alf_prop_link(root_prop_id, key_prop_id, value_prop_id);
|
||||
CREATE INDEX fk_alf_propln_key ON alf_prop_link(key_prop_id);
|
||||
CREATE INDEX fk_alf_propln_val ON alf_prop_link(value_prop_id);
|
||||
|
||||
CREATE SEQUENCE alf_prop_unique_ctx_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_prop_unique_ctx
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -118,8 +117,9 @@ CREATE TABLE alf_prop_unique_ctx
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_alf_propuctx ON alf_prop_unique_ctx(value1_prop_id, value2_prop_id, value3_prop_id);
|
||||
|
||||
CREATE SEQUENCE alf_prop_unique_ctx_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE INDEX fk_alf_propuctx_v2 ON alf_prop_unique_ctx(value2_prop_id);
|
||||
CREATE INDEX fk_alf_propuctx_v3 ON alf_prop_unique_ctx(value3_prop_id);
|
||||
CREATE INDEX fk_alf_propuctx_p1 ON alf_prop_unique_ctx(prop1_id);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
|
@@ -23,6 +23,7 @@ CREATE TABLE alf_applied_patch
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE alf_namespace_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_namespace
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -30,10 +31,9 @@ CREATE TABLE alf_namespace
|
||||
uri VARCHAR(100) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uri ON alf_namespace (uri);
|
||||
CREATE SEQUENCE alf_namespace_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_qname_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_qname
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -45,8 +45,8 @@ CREATE TABLE alf_qname
|
||||
);
|
||||
CREATE UNIQUE INDEX ns_id ON alf_qname (ns_id, local_name);
|
||||
CREATE INDEX fk_alf_qname_ns ON alf_qname (ns_id);
|
||||
CREATE SEQUENCE alf_qname_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_permission_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_permission
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -58,8 +58,8 @@ CREATE TABLE alf_permission
|
||||
);
|
||||
CREATE UNIQUE INDEX type_qname_id ON alf_permission (type_qname_id, name);
|
||||
CREATE INDEX fk_alf_perm_tqn ON alf_permission (type_qname_id);
|
||||
CREATE SEQUENCE alf_permission_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_ace_context_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_ace_context
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -69,8 +69,8 @@ CREATE TABLE alf_ace_context
|
||||
kvp_context VARCHAR(1024),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_ace_context_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_authority_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_authority
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -81,8 +81,8 @@ CREATE TABLE alf_authority
|
||||
);
|
||||
CREATE UNIQUE INDEX authority ON alf_authority (authority, crc);
|
||||
CREATE INDEX idx_alf_auth_aut ON alf_authority (authority);
|
||||
CREATE SEQUENCE alf_authority_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_access_control_entry_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_access_control_entry
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -101,16 +101,16 @@ CREATE UNIQUE INDEX permission_id ON alf_access_control_entry (permission_id, au
|
||||
CREATE INDEX fk_alf_ace_ctx ON alf_access_control_entry (context_id);
|
||||
CREATE INDEX fk_alf_ace_perm ON alf_access_control_entry (permission_id);
|
||||
CREATE INDEX fk_alf_ace_auth ON alf_access_control_entry (authority_id);
|
||||
CREATE SEQUENCE alf_access_control_entry_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_acl_change_set_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_acl_change_set
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
version INT8 NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_acl_change_set_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_access_control_list_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_access_control_list
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -131,8 +131,8 @@ CREATE TABLE alf_access_control_list
|
||||
CREATE UNIQUE INDEX acl_id ON alf_access_control_list (acl_id, latest, acl_version);
|
||||
CREATE INDEX idx_alf_acl_inh ON alf_access_control_list (inherits, inherits_from);
|
||||
CREATE INDEX fk_alf_acl_acs ON alf_access_control_list (acl_change_set);
|
||||
CREATE SEQUENCE alf_access_control_list_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_acl_member_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_acl_member
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -147,8 +147,8 @@ CREATE TABLE alf_acl_member
|
||||
CREATE UNIQUE INDEX aclm_acl_id ON alf_acl_member (acl_id, ace_id, pos);
|
||||
CREATE INDEX fk_alf_aclm_acl ON alf_acl_member (acl_id);
|
||||
CREATE INDEX fk_alf_aclm_ace ON alf_acl_member (ace_id);
|
||||
CREATE SEQUENCE alf_acl_member_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_authority_alias_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_authority_alias
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -162,96 +162,8 @@ CREATE TABLE alf_authority_alias
|
||||
CREATE UNIQUE INDEX auth_id ON alf_authority_alias (auth_id, alias_id);
|
||||
CREATE INDEX fk_alf_autha_ali ON alf_authority_alias (alias_id);
|
||||
CREATE INDEX fk_alf_autha_aut ON alf_authority_alias (auth_id);
|
||||
CREATE SEQUENCE alf_authority_alias_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_audit_config
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
config_url VARCHAR(1024) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE SEQUENCE alf_audit_config_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_audit_date
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
date_only DATE NOT NULL,
|
||||
day_of_year INT4 NOT NULL,
|
||||
day_of_month INT4 NOT NULL,
|
||||
day_of_week INT4 NOT NULL,
|
||||
week_of_year INT4 NOT NULL,
|
||||
week_of_month INT4 NOT NULL,
|
||||
month INT4 NOT NULL,
|
||||
quarter INT4 NOT NULL,
|
||||
half_year INT4 NOT NULL,
|
||||
full_year INT4 NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX idx_alf_adtd_woy ON alf_audit_date (week_of_year);
|
||||
CREATE INDEX idx_alf_adtd_fy ON alf_audit_date (full_year);
|
||||
CREATE INDEX idx_alf_adtd_q ON alf_audit_date (quarter);
|
||||
CREATE INDEX idx_alf_adtd_wom ON alf_audit_date (week_of_month);
|
||||
CREATE INDEX idx_alf_adtd_dom ON alf_audit_date (day_of_month);
|
||||
CREATE INDEX idx_alf_adtd_doy ON alf_audit_date (day_of_year);
|
||||
CREATE INDEX idx_alf_adtd_dow ON alf_audit_date (day_of_week);
|
||||
CREATE INDEX idx_alf_adtd_m ON alf_audit_date (month);
|
||||
CREATE INDEX idx_alf_adtd_hy ON alf_audit_date (half_year);
|
||||
CREATE INDEX idx_alf_adtd_dat ON alf_audit_date (date_only);
|
||||
CREATE SEQUENCE alf_audit_date_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_audit_source
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
application VARCHAR(255) NOT NULL,
|
||||
service VARCHAR(255),
|
||||
method VARCHAR(255),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX idx_alf_adts_met ON alf_audit_source (method);
|
||||
CREATE INDEX idx_alf_adts_ser ON alf_audit_source (service);
|
||||
CREATE INDEX idx_alf_adts_app ON alf_audit_source (application);
|
||||
CREATE SEQUENCE alf_audit_source_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_audit_fact
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
user_id VARCHAR(255) NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL,
|
||||
transaction_id VARCHAR(56) NOT NULL,
|
||||
session_id VARCHAR(56),
|
||||
store_protocol VARCHAR(50),
|
||||
store_id VARCHAR(100),
|
||||
node_uuid VARCHAR(36),
|
||||
path VARCHAR(1024),
|
||||
filtered BOOL NOT NULL,
|
||||
return_val VARCHAR(1024),
|
||||
arg_1 VARCHAR(1024),
|
||||
arg_2 VARCHAR(1024),
|
||||
arg_3 VARCHAR(1024),
|
||||
arg_4 VARCHAR(1024),
|
||||
arg_5 VARCHAR(1024),
|
||||
fail BOOL NOT NULL,
|
||||
serialized_url VARCHAR(1024),
|
||||
exception_message VARCHAR(1024),
|
||||
host_address VARCHAR(1024),
|
||||
client_address VARCHAR(1024),
|
||||
message_text VARCHAR(1024),
|
||||
audit_date_id INT8 NOT NULL,
|
||||
audit_conf_id INT8 NOT NULL,
|
||||
audit_source_id INT8 NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT fk_alf_adtf_conf FOREIGN KEY (audit_conf_id) REFERENCES alf_audit_config (id),
|
||||
CONSTRAINT fk_alf_adtf_date FOREIGN KEY (audit_date_id) REFERENCES alf_audit_date (id),
|
||||
CONSTRAINT fk_alf_adtf_src FOREIGN KEY (audit_source_id) REFERENCES alf_audit_source (id)
|
||||
);
|
||||
CREATE INDEX idx_alf_adtf_ref ON alf_audit_fact (store_protocol, store_id, node_uuid);
|
||||
CREATE INDEX idx_alf_adtf_usr ON alf_audit_fact (user_id);
|
||||
CREATE INDEX fk_alf_adtf_src ON alf_audit_fact (audit_source_id);
|
||||
CREATE INDEX fk_alf_adtf_date ON alf_audit_fact (audit_date_id);
|
||||
CREATE INDEX fk_alf_adtf_conf ON alf_audit_fact (audit_conf_id);
|
||||
CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path);
|
||||
CREATE SEQUENCE alf_audit_fact_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_server_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_server
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -260,8 +172,8 @@ CREATE TABLE alf_server
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX ip_address ON alf_server (ip_address);
|
||||
CREATE SEQUENCE alf_server_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_transaction_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_transaction
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -274,8 +186,8 @@ CREATE TABLE alf_transaction
|
||||
);
|
||||
CREATE INDEX idx_alf_txn_ctms ON alf_transaction (commit_time_ms);
|
||||
CREATE INDEX fk_alf_txn_svr ON alf_transaction (server_id);
|
||||
CREATE SEQUENCE alf_transaction_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_store_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_store
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -286,8 +198,8 @@ CREATE TABLE alf_store
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX protocol ON alf_store (protocol, identifier);
|
||||
CREATE SEQUENCE alf_store_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_node_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_node
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -315,11 +227,11 @@ CREATE INDEX fk_alf_node_acl ON alf_node (acl_id);
|
||||
CREATE INDEX fk_alf_node_txn ON alf_node (transaction_id);
|
||||
CREATE INDEX fk_alf_node_store ON alf_node (store_id);
|
||||
CREATE INDEX fk_alf_node_tqn ON alf_node (type_qname_id);
|
||||
CREATE SEQUENCE alf_node_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX fk_alf_store_root ON alf_store (root_node_id);
|
||||
ALTER TABLE alf_store ADD CONSTRAINT fk_alf_store_root FOREIGN KEY (root_node_id) REFERENCES alf_node (id);
|
||||
|
||||
CREATE SEQUENCE alf_child_assoc_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_child_assoc
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -347,8 +259,8 @@ CREATE INDEX fk_alf_cass_tqn ON alf_child_assoc (type_qname_id);
|
||||
CREATE INDEX fk_alf_cass_qnns ON alf_child_assoc (qname_ns_id);
|
||||
CREATE INDEX idx_alf_cass_qncrc ON alf_child_assoc (qname_crc, type_qname_id, parent_node_id);
|
||||
CREATE INDEX idx_alf_cass_pri ON alf_child_assoc (parent_node_id, is_primary, child_node_id);
|
||||
CREATE SEQUENCE alf_child_assoc_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_locale_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_locale
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -357,8 +269,8 @@ CREATE TABLE alf_locale
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX locale_str ON alf_locale (locale_str);
|
||||
CREATE SEQUENCE alf_locale_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_attributes_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_attributes
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -378,7 +290,6 @@ CREATE TABLE alf_attributes
|
||||
CONSTRAINT fk_alf_attr_acl FOREIGN KEY (acl_id) REFERENCES alf_access_control_list (id)
|
||||
);
|
||||
CREATE INDEX fk_alf_attr_acl ON alf_attributes (acl_id);
|
||||
CREATE SEQUENCE alf_attributes_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_global_attributes
|
||||
(
|
||||
@@ -425,6 +336,7 @@ CREATE TABLE alf_node_aspects
|
||||
CREATE INDEX fk_alf_nasp_n ON alf_node_aspects (node_id);
|
||||
CREATE INDEX fk_alf_nasp_qn ON alf_node_aspects (qname_id);
|
||||
|
||||
CREATE SEQUENCE alf_node_assoc_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_node_assoc
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -441,7 +353,6 @@ CREATE UNIQUE INDEX source_node_id ON alf_node_assoc (source_node_id, target_nod
|
||||
CREATE INDEX fk_alf_nass_snode ON alf_node_assoc (source_node_id);
|
||||
CREATE INDEX fk_alf_nass_tnode ON alf_node_assoc (target_node_id);
|
||||
CREATE INDEX fk_alf_nass_tqn ON alf_node_assoc (type_qname_id);
|
||||
CREATE SEQUENCE alf_node_assoc_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE TABLE alf_node_properties
|
||||
(
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
CREATE SEQUENCE alf_usage_delta_seq START WITH 1 INCREMENT BY 1; -- (optional)
|
||||
CREATE TABLE alf_usage_delta
|
||||
(
|
||||
id INT8 NOT NULL,
|
||||
@@ -17,7 +18,6 @@ CREATE TABLE alf_usage_delta
|
||||
CONSTRAINT fk_alf_usaged_n FOREIGN KEY (node_id) REFERENCES alf_node (id)
|
||||
); -- (optional)
|
||||
CREATE INDEX fk_alf_usaged_n ON alf_usage_delta (node_id); -- (optional)
|
||||
CREATE SEQUENCE alf_usage_delta_seq START WITH 1 INCREMENT BY 1; -- (optional)
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
|
@@ -23,10 +23,6 @@ CREATE INDEX fk_alf_aclm_ace ON alf_acl_member (ace_id);
|
||||
|
||||
CREATE INDEX fk_alf_attr_acl ON alf_attributes (acl_id);
|
||||
|
||||
CREATE INDEX fk_alf_adtf_src ON alf_audit_fact (audit_source_id);
|
||||
CREATE INDEX fk_alf_adtf_date ON alf_audit_fact (audit_date_id);
|
||||
CREATE INDEX fk_alf_adtf_conf ON alf_audit_fact (audit_conf_id);
|
||||
|
||||
CREATE INDEX fk_alf_autha_ali ON alf_authority_alias (alias_id);
|
||||
CREATE INDEX fk_alf_autha_aut ON alf_authority_alias (auth_id);
|
||||
|
||||
|
@@ -1,23 +0,0 @@
|
||||
--
|
||||
-- Title: Ensure the audit table path column is indexed
|
||||
-- Database: Generic
|
||||
-- Since: V2.1 Schema 82
|
||||
-- Author: Andy Hind
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
-- Path was previously unused and unindex - new we use it the index is required.
|
||||
|
||||
CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.1-AuditPathIndex';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V2.1-AuditPathIndex', 'Manually executed script upgrade V2.1: Ensure existence of audit path index',
|
||||
0, 81, -1, 82, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
|
||||
);
|
@@ -1,23 +0,0 @@
|
||||
--
|
||||
-- Title: Ensure the audit table path column is indexed
|
||||
-- Database: Generic
|
||||
-- Since: V2.1 Schema 82
|
||||
-- Author: Andy Hind
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
-- Path was previously unused and unindex - new we use it the index is required.
|
||||
|
||||
CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path(128));
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.1-AuditPathIndex';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V2.1-AuditPathIndex', 'Manually executed script upgrade V2.1: Ensure existence of audit path index',
|
||||
0, 81, -1, 82, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
|
||||
);
|
@@ -10,11 +10,6 @@
|
||||
-- to simplify subsequent upgrade scripts.
|
||||
--
|
||||
|
||||
-- Fix alf_audit_date column names
|
||||
|
||||
ALTER TABLE alf_audit_date CHANGE COLUMN halfYear half_year INTEGER NOT NULL;
|
||||
ALTER TABLE alf_audit_date CHANGE COLUMN year full_year INTEGER NOT NULL;
|
||||
|
||||
-- create other new tables
|
||||
|
||||
create table avm_aspects (
|
||||
|
@@ -966,56 +966,6 @@ ALTER TABLE alf_attributes
|
||||
ADD INDEX fk_alf_attr_acl (acl_id)
|
||||
;
|
||||
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_woy_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_date_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_y_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_q_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_m_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_dow_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_doy_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_dom_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_hy_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date DROP INDEX adt_wom_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_date
|
||||
ADD INDEX idx_alf_adtd_woy (week_of_year),
|
||||
ADD INDEX idx_alf_adtd_q (quarter),
|
||||
ADD INDEX idx_alf_adtd_wom (week_of_month),
|
||||
ADD INDEX idx_alf_adtd_dom (day_of_month),
|
||||
ADD INDEX idx_alf_adtd_doy (day_of_year),
|
||||
ADD INDEX idx_alf_adtd_dow (day_of_week),
|
||||
ADD INDEX idx_alf_adtd_m (month),
|
||||
ADD INDEX idx_alf_adtd_hy (half_year),
|
||||
ADD INDEX idx_alf_adtd_fy (full_year),
|
||||
ADD INDEX idx_alf_adtd_dat (date_only)
|
||||
;
|
||||
|
||||
ALTER TABLE alf_audit_fact DROP INDEX adt_user_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_fact DROP INDEX adt_store_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_fact
|
||||
DROP INDEX FKEAD18174A0F9B8D9, DROP FOREIGN KEY FKEAD18174A0F9B8D9,
|
||||
DROP INDEX FKEAD1817484342E39, DROP FOREIGN KEY FKEAD1817484342E39,
|
||||
DROP INDEX FKEAD18174F524CFD7, DROP FOREIGN KEY FKEAD18174F524CFD7
|
||||
;
|
||||
ALTER TABLE alf_audit_fact
|
||||
ADD INDEX idx_alf_adtf_ref (store_protocol, store_id, node_uuid),
|
||||
ADD INDEX idx_alf_adtf_usr (user_id),
|
||||
ADD INDEX fk_alf_adtf_src (audit_source_id),
|
||||
ADD CONSTRAINT fk_alf_adtf_src FOREIGN KEY (audit_source_id) REFERENCES alf_audit_source (id),
|
||||
ADD INDEX fk_alf_adtf_date (audit_date_id),
|
||||
ADD CONSTRAINT fk_alf_adtf_date FOREIGN KEY (audit_date_id) REFERENCES alf_audit_date (id),
|
||||
ADD INDEX fk_alf_adtf_conf (audit_conf_id),
|
||||
ADD CONSTRAINT fk_alf_adtf_conf FOREIGN KEY (audit_conf_id) REFERENCES alf_audit_config (id)
|
||||
;
|
||||
|
||||
ALTER TABLE alf_audit_source DROP INDEX app_source_app_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_source DROP INDEX app_source_ser_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_source DROP INDEX app_source_met_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_source
|
||||
ADD INDEX idx_alf_adts_met (method),
|
||||
ADD INDEX idx_alf_adts_ser (service),
|
||||
ADD INDEX idx_alf_adts_app (application)
|
||||
;
|
||||
|
||||
ALTER TABLE alf_global_attributes DROP FOREIGN KEY FK64D0B9CF69B9F16A; -- (optional)
|
||||
ALTER TABLE alf_global_attributes DROP INDEX FK64D0B9CF69B9F16A; -- (optional)
|
||||
-- alf_global_attributes.attribute is declared unique. Indexes may automatically have been created.
|
||||
|
@@ -1,23 +0,0 @@
|
||||
--
|
||||
-- Title: Ensure the audit table path column is indexed
|
||||
-- Database: PostgreSQL
|
||||
-- Since: V2.1 Schema 82
|
||||
-- Author: Andy Hind
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
-- Path was previously unused and unindex - new we use it the index is required.
|
||||
|
||||
CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.1-AuditPathIndex';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V2.1-AuditPathIndex', 'Manually executed script upgrade V2.1: Ensure existence of audit path index',
|
||||
0, 81, -1, 82, null, 'UNKNOWN', TRUE, TRUE, 'Script completed'
|
||||
);
|
@@ -10,11 +10,6 @@
|
||||
-- to simplify subsequent upgrade scripts.
|
||||
--
|
||||
|
||||
-- Fix alf_audit_date column names
|
||||
|
||||
ALTER TABLE alf_audit_date RENAME halfYear TO half_year;
|
||||
ALTER TABLE alf_audit_date RENAME year TO full_year;
|
||||
|
||||
-- create other new tables
|
||||
|
||||
create table avm_aspects (
|
||||
|
@@ -932,55 +932,6 @@ DROP INDEX fk_attributes_n_acl; -- (optional)
|
||||
DROP INDEX fk_attr_n_acl; -- (optional)
|
||||
CREATE INDEX fk_alf_attr_acl ON alf_attributes (acl_id);
|
||||
|
||||
DROP INDEX adt_woy_idx; -- (optional)
|
||||
DROP INDEX adt_date_idx; -- (optional)
|
||||
DROP INDEX adt_y_idx; -- (optional)
|
||||
DROP INDEX adt_q_idx; -- (optional)
|
||||
DROP INDEX adt_m_idx; -- (optional)
|
||||
DROP INDEX adt_dow_idx; -- (optional)
|
||||
DROP INDEX adt_doy_idx; -- (optional)
|
||||
DROP INDEX adt_dom_idx; -- (optional)
|
||||
DROP INDEX adt_hy_idx; -- (optional)
|
||||
DROP INDEX adt_wom_idx; -- (optional)
|
||||
CREATE INDEX idx_alf_adtd_woy ON alf_audit_date (week_of_year);
|
||||
CREATE INDEX idx_alf_adtd_q ON alf_audit_date (quarter);
|
||||
CREATE INDEX idx_alf_adtd_wom ON alf_audit_date (week_of_month);
|
||||
CREATE INDEX idx_alf_adtd_dom ON alf_audit_date (day_of_month);
|
||||
CREATE INDEX idx_alf_adtd_doy ON alf_audit_date (day_of_year);
|
||||
CREATE INDEX idx_alf_adtd_dow ON alf_audit_date (day_of_week);
|
||||
CREATE INDEX idx_alf_adtd_m ON alf_audit_date (month);
|
||||
CREATE INDEX idx_alf_adtd_hy ON alf_audit_date (half_year);
|
||||
CREATE INDEX idx_alf_adtd_fy ON alf_audit_date (full_year);
|
||||
CREATE INDEX idx_alf_adtd_dat ON alf_audit_date (date_only);
|
||||
|
||||
DROP INDEX adt_user_idx; -- (optional)
|
||||
DROP INDEX adt_store_idx; -- (optional)
|
||||
ALTER TABLE alf_audit_fact
|
||||
DROP CONSTRAINT FKEAD18174A0F9B8D9,
|
||||
DROP CONSTRAINT FKEAD1817484342E39,
|
||||
DROP CONSTRAINT FKEAD18174F524CFD7
|
||||
;
|
||||
DROP INDEX FKEAD18174A0F9B8D9;
|
||||
DROP INDEX FKEAD1817484342E39;
|
||||
DROP INDEX FKEAD18174F524CFD7;
|
||||
ALTER TABLE alf_audit_fact
|
||||
ADD CONSTRAINT fk_alf_adtf_src FOREIGN KEY (audit_source_id) REFERENCES alf_audit_source (id),
|
||||
ADD CONSTRAINT fk_alf_adtf_date FOREIGN KEY (audit_date_id) REFERENCES alf_audit_date (id),
|
||||
ADD CONSTRAINT fk_alf_adtf_conf FOREIGN KEY (audit_conf_id) REFERENCES alf_audit_config (id)
|
||||
;
|
||||
CREATE INDEX idx_alf_adtf_ref ON alf_audit_fact (store_protocol, store_id, node_uuid);
|
||||
CREATE INDEX idx_alf_adtf_usr ON alf_audit_fact (user_id);
|
||||
CREATE INDEX fk_alf_adtf_src ON alf_audit_fact (audit_source_id);
|
||||
CREATE INDEX fk_alf_adtf_date ON alf_audit_fact (audit_date_id);
|
||||
CREATE INDEX fk_alf_adtf_conf ON alf_audit_fact (audit_conf_id);
|
||||
|
||||
DROP INDEX app_source_app_idx; -- (optional)
|
||||
DROP INDEX app_source_ser_idx; -- (optional)
|
||||
DROP INDEX app_source_met_idx; -- (optional)
|
||||
CREATE INDEX idx_alf_adts_met ON alf_audit_source (method);
|
||||
CREATE INDEX idx_alf_adts_ser ON alf_audit_source (service);
|
||||
CREATE INDEX idx_alf_adts_app ON alf_audit_source (application);
|
||||
|
||||
ALTER TABLE alf_global_attributes DROP CONSTRAINT FK64D0B9CF69B9F16A; -- (optional)
|
||||
DROP INDEX FK64D0B9CF69B9F16A; -- (optional)
|
||||
-- alf_global_attributes.attribute is declared unique. Indexes may automatically have been created.
|
||||
|
@@ -0,0 +1,63 @@
|
||||
--
|
||||
-- Title: Upgrade to V3.2 - Add extra FK indexes
|
||||
-- Database: Generic
|
||||
-- Since: V3.2 schema 3503
|
||||
-- Author: Derek Hulley
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
-- ALF-5396: Missing FK indexes on non-MySQL databases
|
||||
-- All statements are made optional to cater for varying introductions of tables
|
||||
-- using create scripts that have been fixed up.
|
||||
|
||||
-- ==========
|
||||
-- V3.2 diffs
|
||||
-- ==========
|
||||
|
||||
-- alf_audit_* tables
|
||||
CREATE INDEX fk_alf_aud_mod_cd ON alf_audit_model(content_data_id); -- (optional)
|
||||
CREATE INDEX fk_alf_aud_app_mod ON alf_audit_app(audit_model_id); -- (optional)
|
||||
CREATE INDEX fk_alf_aud_app_dis ON alf_audit_app(disabled_paths_id); -- (optional)
|
||||
CREATE INDEX fk_alf_aud_ent_app ON alf_audit_entry(audit_app_id); -- (optional)
|
||||
CREATE INDEX fk_alf_aud_ent_use ON alf_audit_entry(audit_user_id); -- (optional)
|
||||
CREATE INDEX fk_alf_aud_ent_pro ON alf_audit_entry(audit_values_id); -- (optional)
|
||||
|
||||
-- Only missing on Oracle
|
||||
ALTER TABLE avm_stores
|
||||
ADD CONSTRAINT fk_avm_s_acl
|
||||
FOREIGN KEY (acl_id)
|
||||
REFERENCES alf_access_control_list (id); -- (optional)
|
||||
CREATE INDEX fk_avm_s_acl ON avm_stores (acl_id); -- (optional)
|
||||
|
||||
-- alf_content_* tables
|
||||
CREATE INDEX fk_alf_cont_url ON alf_content_data (content_url_id); -- (optional)
|
||||
CREATE INDEX fk_alf_cont_mim ON alf_content_data (content_mimetype_id); -- (optional)
|
||||
CREATE INDEX fk_alf_cont_enc ON alf_content_data (content_encoding_id); -- (optional)
|
||||
CREATE INDEX fk_alf_cont_loc ON alf_content_data (content_locale_id); -- (optional)
|
||||
|
||||
-- alf_lock_* tables
|
||||
CREATE INDEX fk_alf_lock_excl ON alf_lock (excl_resource_id); -- (optional)
|
||||
|
||||
-- alf_prop_* tables
|
||||
CREATE INDEX fk_alf_propln_key ON alf_prop_link(key_prop_id); -- (optional)
|
||||
CREATE INDEX fk_alf_propln_val ON alf_prop_link(value_prop_id); -- (optional)
|
||||
CREATE INDEX fk_alf_propuctx_v2 ON alf_prop_unique_ctx(value2_prop_id); -- (optional)
|
||||
CREATE INDEX fk_alf_propuctx_v3 ON alf_prop_unique_ctx(value3_prop_id); -- (optional)
|
||||
|
||||
-- ==========
|
||||
-- V3.4 diffs
|
||||
-- ==========
|
||||
|
||||
CREATE INDEX fk_alf_propuctx_p1 ON alf_prop_unique_ctx(prop1_id); -- (optional)
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-AddFKIndexes-2';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.2-AddFKIndexes-2', 'Script fix for ALF-5396: Missing FK indexes on non-MySQL databases',
|
||||
0, 4111, -1, 4112, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed'
|
||||
);
|
@@ -0,0 +1,23 @@
|
||||
--
|
||||
-- Title: Upgrade to V3.2 - Add extra FK indexes
|
||||
-- Database: MySQL
|
||||
-- Since: V3.2 schema 3503
|
||||
-- Author: Derek Hulley
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
-- ALF-5396: Missing FK indexes on non-MySQL databases
|
||||
-- Not relevant to MySQL
|
||||
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.2-AddFKIndexes-2';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.2-AddFKIndexes-2', 'Script fix for ALF-5396: Missing FK indexes on non-MySQL databases',
|
||||
0, 4111, -1, 4112, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed'
|
||||
);
|
@@ -32,14 +32,6 @@ CREATE SEQUENCE alf_acl_member_seq START WITH ${hibernate_seq_next_value} INCREM
|
||||
|
||||
CREATE SEQUENCE alf_authority_alias_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_audit_config_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_audit_date_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_audit_source_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_audit_fact_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_server_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
||||
CREATE SEQUENCE alf_transaction_seq START WITH ${hibernate_seq_next_value} INCREMENT BY 1;
|
||||
|
@@ -125,8 +125,8 @@
|
||||
disabled_paths_id = #disabledPathsId#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
and version = ((#version#-1))
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
|
@@ -369,7 +369,7 @@
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
<isGreaterThan property="vers" compareValue="0">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -600,7 +600,7 @@
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
<isGreaterThan property="vers" compareValue="0">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -614,7 +614,7 @@
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
<isGreaterThan property="vers" compareValue="0">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -631,7 +631,7 @@
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
<isGreaterThan property="vers" compareValue="0">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
@@ -207,7 +207,7 @@
|
||||
mimetype_str = #mimetype#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -277,7 +277,7 @@
|
||||
content_locale_id = #localeId#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
@@ -121,8 +121,10 @@
|
||||
start_time = #startTime#,
|
||||
expiry_time = #expiryTime#
|
||||
where
|
||||
id = #id# and
|
||||
version = (#version# -1)
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
<!-- Update locks for a given exclusive lock -->
|
||||
|
@@ -366,7 +366,7 @@
|
||||
</isEqual>
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -394,7 +394,8 @@
|
||||
parent_node_id = #parentNode.id# and
|
||||
type_qname_id = #typeQNameId# and
|
||||
qname_ns_id = #qnameNamespaceId# and
|
||||
qname_localname = #qnameLocalName#
|
||||
qname_localname = #qnameLocalName# and
|
||||
child_node_id = #childNode.id#
|
||||
</update>
|
||||
|
||||
<update id="update_ParentAssocsOfChild" parameterClass="ChildAssoc">
|
||||
@@ -770,7 +771,7 @@
|
||||
parentNode.id = #parentNode.id#
|
||||
<isNotNull property="childNode">and assoc.child_node_id = #childNode.id#</isNotNull>
|
||||
<isNotNull property="typeQNameIds">
|
||||
and type_qname_id in <iterate property="typeQNameIds" open="(" close=")" conjunction=",">#typeQNameIds[]#</iterate>
|
||||
and assoc.type_qname_id in <iterate property="typeQNameIds" open="(" close=")" conjunction=",">#typeQNameIds[]#</iterate>
|
||||
</isNotNull>
|
||||
<isNotNull property="typeQNameId">and assoc.type_qname_id = #typeQNameId#</isNotNull>
|
||||
<isNotNull property="qnameCrc">and assoc.qname_crc = #qnameCrc#</isNotNull>
|
||||
|
@@ -12,6 +12,8 @@
|
||||
|
||||
<typeAlias alias="Ids" type="org.alfresco.ibatis.IdsEntity"/>
|
||||
|
||||
<typeAlias alias="DuplicateEntry" type="org.alfresco.repo.admin.patch.impl.DuplicateEntry" />
|
||||
|
||||
<!-- -->
|
||||
<!-- Result Maps -->
|
||||
<!-- -->
|
||||
@@ -70,6 +72,13 @@
|
||||
<result property="lastModified" column="lastModified" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="result_DuplicateEntry" class="DuplicateEntry">
|
||||
<result property="id" column="child_id" jdbcType="BIGINT" javaType="java.lang.Long" />
|
||||
<result property="parentId" column="parent_id" jdbcType="BIGINT" javaType="java.lang.Long" />
|
||||
<result property="name" column="name" jdbcType="VARCHAR" javaType="java.lang.String" />
|
||||
<result property="amount" column="cnt" jdbcType="BIGINT" javaType="java.lang.Long" />
|
||||
</resultMap>
|
||||
|
||||
<!-- -->
|
||||
<!-- Parameter Maps -->
|
||||
<!-- -->
|
||||
@@ -103,6 +112,12 @@
|
||||
<parameter property="namePattern" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||
</parameterMap>
|
||||
|
||||
<parameterMap id="parameter_RenamedDuplicateEntry" class="DuplicateEntry">
|
||||
<parameter property="name" jdbcType="VARCHAR" javaType="java.lang.String" />
|
||||
<parameter property="id" jdbcType="BIGINT" javaType="java.lang.Long" />
|
||||
<parameter property="parentId" jdbcType="BIGINT" javaType="java.lang.Long" />
|
||||
</parameterMap>
|
||||
|
||||
<!-- -->
|
||||
<!-- Selects -->
|
||||
<!-- -->
|
||||
@@ -320,6 +335,30 @@
|
||||
acl_id > ?
|
||||
</select>
|
||||
|
||||
<select id="select_AvmNodeDuplicates" resultMap="result_DuplicateEntry">
|
||||
<![CDATA[
|
||||
select
|
||||
ce.child_id, ce.parent_id, ce.name, entities.cnt
|
||||
from
|
||||
avm_child_entries ce,
|
||||
(
|
||||
select
|
||||
ce2.parent_id, lower(ce2.name) as lname, count(*) as cnt
|
||||
from
|
||||
avm_child_entries ce2
|
||||
group by
|
||||
ce2.parent_id, lower(ce2.name)
|
||||
having
|
||||
count(*) > 1
|
||||
) entities
|
||||
where
|
||||
(ce.parent_id = entities.parent_id)
|
||||
and (lower(ce.name) = entities.lname)
|
||||
order by
|
||||
parent_id, lower(name), child_id
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- -->
|
||||
<!-- Updates -->
|
||||
<!-- -->
|
||||
@@ -358,6 +397,16 @@
|
||||
id = ?
|
||||
</update>
|
||||
|
||||
<update id="update_AvmNodeNameById" parameterMap="parameter_RenamedDuplicateEntry">
|
||||
update
|
||||
avm_child_entries
|
||||
set
|
||||
name = ?
|
||||
where
|
||||
child_id = ?
|
||||
and parent_id = ?
|
||||
</update>
|
||||
|
||||
<!-- -->
|
||||
<!-- Deletes -->
|
||||
<!-- -->
|
||||
|
@@ -277,7 +277,7 @@
|
||||
version = #version#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -293,7 +293,7 @@
|
||||
version = #version#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -308,7 +308,7 @@
|
||||
version = #version#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
@@ -323,7 +323,7 @@
|
||||
version = #version#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
@@ -435,8 +435,8 @@
|
||||
version = #version#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
and version = ((#version#-1))
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
@@ -510,8 +510,8 @@
|
||||
prop1_id = #propertyId#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="version" compareValue="1">
|
||||
and version = ((#version#-1))
|
||||
<isGreaterThan property="version" compareValue="0">
|
||||
and version = (#version#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
|
@@ -349,9 +349,12 @@ patch.fixAuthoritiesCrcValues.fixed=Updated CRC32 values for authority '{0}'.
|
||||
patch.fixAuthoritiesCrcValues.unableToChange=Failed to update the CRC32 value for authority: \n Authority: {0} \n Error: {1}
|
||||
|
||||
patch.updateMimetypes1.description=Fix mimetypes for Excel and Powerpoint.
|
||||
patch.updateMimetypes2.description=Fix mimetypes for Excel and Powerpoint.
|
||||
|
||||
patch.db-V3.2-AddFKIndexes.description=Fixes ALF-3189: Added missing FK indexes. Note: The script is empty for MySQL.
|
||||
|
||||
patch.eliminateDuplicates.description=Fixes ALF-4203: Searches for AVM duplicate nodes and changes their name
|
||||
|
||||
patch.migrateAttrTenants.description=Migrate old Tenant attributes
|
||||
patch.migrateAttrTenants.result=Processed {0} attributes
|
||||
|
||||
|
@@ -1259,15 +1259,12 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.db-V2.1-AuditPathIndex" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
|
||||
<bean id="patch.db-V2.1-AuditPathIndex" class="org.alfresco.repo.admin.patch.impl.NoOpPatch" parent="basePatch">
|
||||
<property name="id"><value>patch.db-V2.1-AuditPathIndex</value></property>
|
||||
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>
|
||||
<property name="fixesFromSchema"><value>0</value></property>
|
||||
<property name="fixesToSchema"><value>132</value></property>
|
||||
<property name="targetSchema"><value>133</value></property>
|
||||
<property name="scriptUrl">
|
||||
<value>classpath:alfresco/dbscripts/upgrade/2.2/${db.script.dialect}/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.spacesStoreGuestPermission" class="org.alfresco.repo.admin.patch.impl.SpacesStoreGuestPermissionPatch" parent="basePatch" >
|
||||
@@ -2264,6 +2261,7 @@
|
||||
<property name="dependsOn" >
|
||||
<list>
|
||||
<ref bean="patch.db-V3.4-property-unique-ctx-value"/>
|
||||
<ref bean="patch.eliminateDuplicates"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
@@ -2466,4 +2464,26 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.db-V3.2-AddFKIndexes-2" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
|
||||
<property name="id"><value>patch.db-V3.2-AddFKIndexes-2</value></property>
|
||||
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>
|
||||
<property name="fixesFromSchema"><value>0</value></property>
|
||||
<property name="fixesToSchema"><value>4111</value></property>
|
||||
<property name="targetSchema"><value>4112</value></property>
|
||||
<property name="scriptUrl">
|
||||
<value>classpath:alfresco/dbscripts/upgrade/3.2/${db.script.dialect}/AlfrescoSchemaUpdate-3.2-AddFKIndexes-2.sql</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.eliminateDuplicates" class="org.alfresco.repo.admin.patch.impl.EliminateDuplicatesPatch" parent="basePatch" >
|
||||
<property name="id" value="patch.eliminateDuplicates" />
|
||||
<property name="description" value="patch.eliminateDuplicates.description" />
|
||||
<property name="fixesFromSchema" value="0" />
|
||||
<property name="fixesToSchema" value="4112" />
|
||||
<property name="targetSchema" value="4113" />
|
||||
<property name="force" value="true" />
|
||||
<property name="template" ref="avmSqlMapClientTemplate" />
|
||||
<property name="temporaryExtension" value="temp" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@@ -19,4 +19,4 @@ version.build=@build-number@
|
||||
|
||||
# Schema number
|
||||
|
||||
version.schema=4111
|
||||
version.schema=4113
|
||||
|
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
/**
|
||||
* Wrapper for duplicate entries
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class DuplicateEntry
|
||||
{
|
||||
private static final int ODD_MULTIPLICATOR = 37;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long amount;
|
||||
|
||||
public DuplicateEntry()
|
||||
{
|
||||
}
|
||||
|
||||
public DuplicateEntry(Long id, Long parentId, String name, Long amount)
|
||||
{
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getAmount()
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(Long amount)
|
||||
{
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof DuplicateEntry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DuplicateEntry converted = (DuplicateEntry) obj;
|
||||
return (id == converted.getId()) && (parentId == converted.getParentId()) && ((null == name) ? (null == converted.getName()) : (name.equals(converted.getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = (int) id.intValue();
|
||||
result = DuplicateEntry.ODD_MULTIPLICATOR * result + (int) parentId.longValue();
|
||||
result = DuplicateEntry.ODD_MULTIPLICATOR * result + (int) amount.longValue();
|
||||
result = DuplicateEntry.ODD_MULTIPLICATOR * result + ((null != name) ? (name.hashCode()) : (0));
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.avm.AVMDAOs;
|
||||
import org.alfresco.repo.avm.AVMNode;
|
||||
import org.alfresco.repo.avm.AVMNodeType;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.orm.ibatis.SqlMapClientTemplate;
|
||||
|
||||
/**
|
||||
* ALF-4203
|
||||
*
|
||||
* This patch searches for AVM Node duplicates resulting from case insensitivity issues on
|
||||
* earlier versions of the software (see ALF-1940) and eliminates them by changing the name
|
||||
* of duplicates to make them unique. This is achieved by appending a unique suffix to
|
||||
* duplicate node names.
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class EliminateDuplicatesPatch extends AbstractPatch
|
||||
{
|
||||
private Log LOGGER = LogFactory.getLog(EliminateDuplicatesPatch.class);
|
||||
|
||||
private static final String RENAMED_MARK_KEY = "renamed.duplicate.mark";
|
||||
|
||||
private static final char EXTENSION_DELIMITER = '.';
|
||||
|
||||
private static final char TOKENS_DELIMITER = '-';
|
||||
|
||||
/**
|
||||
* Internationalized mark to indicate renamed duplicate
|
||||
*/
|
||||
private String renamedMark;
|
||||
|
||||
/**
|
||||
* Temporary extension for renamed duplicates. May be 'not set'
|
||||
*/
|
||||
private String temporaryExtension;
|
||||
|
||||
private AvmDuplicatesIBatisDao helper;
|
||||
|
||||
public EliminateDuplicatesPatch()
|
||||
{
|
||||
helper = new AvmDuplicatesIBatisDao();
|
||||
}
|
||||
|
||||
public String getRenamedMark()
|
||||
{
|
||||
if (null == renamedMark)
|
||||
{
|
||||
String mark = I18NUtil.getMessage(RENAMED_MARK_KEY);
|
||||
StringBuilder markBuilder = new StringBuilder().append(TOKENS_DELIMITER);
|
||||
renamedMark = markBuilder.append(mark).append(TOKENS_DELIMITER).toString();
|
||||
}
|
||||
return renamedMark;
|
||||
}
|
||||
|
||||
public void setTemporaryExtension(String temporaryExtension)
|
||||
{
|
||||
this.temporaryExtension = temporaryExtension;
|
||||
}
|
||||
|
||||
public void setTemplate(SqlMapClientTemplate template)
|
||||
{
|
||||
helper.setTemplate(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
int totalRenamed = 0;
|
||||
int duplicateGroupsAmount = 0;
|
||||
|
||||
// Receiving duplicates
|
||||
List<DuplicateEntry> duplicates = helper.getDuplicates();
|
||||
Iterator<DuplicateEntry> duplicatesIterator = duplicates.iterator();
|
||||
DuplicateEntry duplicate = null;
|
||||
|
||||
// duplicates contains all the duplicates found ordered by parent_id, lower(name), child_id.
|
||||
// Within this ordered list there are groups of duplicates (in which the parent_id and lower(name)
|
||||
// are the same but the child_id varies). A duplicate group, by definition, must have two or more entries.
|
||||
while (duplicatesIterator.hasNext() && (null != (duplicate = duplicatesIterator.next())))
|
||||
{
|
||||
// Increasing duplicate groups amount
|
||||
duplicateGroupsAmount++;
|
||||
int renamed = 0;
|
||||
|
||||
// First element of the duplicates group will be left with its current name. Marking first element of current group as marked
|
||||
int processed = 1;
|
||||
|
||||
// amount is the number of duplicates in the current duplicate group
|
||||
long amount = duplicate.getAmount();
|
||||
|
||||
// While we have duplicates and we are still within a duplicates group
|
||||
// amount = the number of duplicates with the same parent and lowercase name
|
||||
// processed = the number of duplicates in the current duplicates group that have been processed
|
||||
while (duplicatesIterator.hasNext() && (amount > processed))
|
||||
{
|
||||
// Skipping first element from each group to leave at least one Node with initial name
|
||||
duplicate = duplicatesIterator.next();
|
||||
processed++;
|
||||
|
||||
String newName = generatePatchedName(duplicate);
|
||||
boolean renamingResult = helper.renameNode(new DuplicateEntry(duplicate.getId(), duplicate.getParentId(), newName, 1L));
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("Trying to rename Node with id = '" + duplicate.getId() + "' and parent id = '"
|
||||
+ duplicate.getParentId() + "' from '" + duplicate.getName() + "' to '" + newName + "'. Result: "
|
||||
+ renamingResult);
|
||||
}
|
||||
if (renamingResult)
|
||||
{
|
||||
renamed++;
|
||||
totalRenamed++;
|
||||
}
|
||||
}
|
||||
|
||||
// Entries finished or another group reached
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("Duplicates for '" + duplicate.getName().toLowerCase() + "' name and parentId='" + duplicate.getParentId() + "': " + duplicate.getAmount()
|
||||
+ ". Renamed: " + renamed);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(duplicateGroupsAmount).append(" duplicate group(s) were found\n");
|
||||
result.append(duplicates.size()).append(" affected node entries\n");
|
||||
result.append("----------------\nTotal renamed: ").append(totalRenamed).append('\n');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* With help of {@link GUID} utility class this method generates unique and internationalized name for some Node. Also returned name will be finished with
|
||||
* {@link EliminateDuplicatesPatch#temporaryExtension} extension if it is not empty or <b><i>null</i></b>
|
||||
*
|
||||
* @param node - {@link DuplicateEntry} instance which contains required old name and Node id
|
||||
* @return {@link String} value which represents unique and internationalized name generated from the duplicated one
|
||||
*/
|
||||
private String generatePatchedName(DuplicateEntry node)
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
StringBuilder extension = new StringBuilder();
|
||||
AVMNode avmNode = AVMDAOs.Instance().fAVMNodeDAO.getByID(node.getId());
|
||||
String oldName = node.getName();
|
||||
if (((AVMNodeType.LAYERED_FILE == avmNode.getType()) || (AVMNodeType.PLAIN_FILE == avmNode.getType())))
|
||||
{
|
||||
int dotPosition = oldName.indexOf(EXTENSION_DELIMITER);
|
||||
if (-1 != dotPosition)
|
||||
{
|
||||
extension.append(oldName.substring(dotPosition));
|
||||
oldName = oldName.substring(0, dotPosition);
|
||||
}
|
||||
if ((null != temporaryExtension) && (temporaryExtension.length() > 0))
|
||||
{
|
||||
extension.append(EXTENSION_DELIMITER).append(temporaryExtension);
|
||||
}
|
||||
}
|
||||
result.append(oldName).append(getRenamedMark()).append(GUID.generate()).append(extension.toString());
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* iBatis helper which introduces functionality for duplicates of some node receiving and renaming in <code>avm_child_entries table</code>
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
private class AvmDuplicatesIBatisDao
|
||||
{
|
||||
private static final String QUERY_SELECT_DUPLICATES_ID = "alfresco.patch.select_AvmNodeDuplicates";
|
||||
|
||||
private static final String QUERY_RENAME_NODE_ID = "alfresco.patch.update_AvmNodeNameById";
|
||||
|
||||
private SqlMapClientTemplate template;
|
||||
|
||||
public void setTemplate(SqlMapClientTemplate template)
|
||||
{
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives all duplicates found in some repository
|
||||
*
|
||||
* @return {@link List}<{@link DuplicateEntry}> list which contains all received duplicates wrapped into the {@link DuplicateEntry}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<DuplicateEntry> getDuplicates()
|
||||
{
|
||||
return template.queryForList(QUERY_SELECT_DUPLICATES_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames some child which is duplicate for some other Node(s) in some Space
|
||||
*
|
||||
* @param renamedEntry - {@link DuplicateEntry} instance which specifies Id and new name for Node
|
||||
* @return {@link Boolean} value which equals to <code>true</code> if renaming update has been finished successfully
|
||||
*/
|
||||
public boolean renameNode(DuplicateEntry renamedEntry)
|
||||
{
|
||||
return template.update(QUERY_RENAME_NODE_ID, renamedEntry) > 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -92,26 +92,29 @@ public class MigrateAttrAVMLocksPatch extends AbstractPatch
|
||||
Map<String, Object> result = (Map<String, Object>)valueObject;
|
||||
|
||||
String wpStoreId = (String)result.get("wpStoreId");
|
||||
String relPath = (String)result.get("relPath");
|
||||
String path = (String)result.get("relPath");
|
||||
String avmStore = (String)result.get("avmStore");
|
||||
String lockOwner = (String)result.get("owner1");
|
||||
|
||||
relPath = AVMLockingServiceImpl.normalizePath(relPath);
|
||||
String relPath = AVMLockingServiceImpl.normalizePath(path);
|
||||
|
||||
HashMap<String, String> lockData = new HashMap<String, String>(2);
|
||||
lockData.put(AVMLockingServiceImpl.KEY_LOCK_OWNER, lockOwner);
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, avmStore);
|
||||
|
||||
attributeService.createAttribute(
|
||||
lockData,
|
||||
AVMLockingServiceImpl.KEY_AVM_LOCKS, wpStoreId, relPath);
|
||||
|
||||
if (!attributeService.exists(AVMLockingServiceImpl.KEY_AVM_LOCKS, wpStoreId, relPath))
|
||||
{
|
||||
attributeService.createAttribute(lockData, AVMLockingServiceImpl.KEY_AVM_LOCKS, wpStoreId, relPath);
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Set AVM Lock attr [wpStoreId=" + wpStoreId + ", relPath=" + relPath + ", lockOwner=" + lockOwner + ", avmStore=" + avmStore + "]");
|
||||
}
|
||||
|
||||
total++;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("'" + path + "' path has duplicates in normalized form. AVM lock unique attribute creation has been skipped");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) ))
|
||||
{
|
||||
|
@@ -39,6 +39,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.ibatis.SerializableTypeHandlerCallback;
|
||||
import org.alfresco.repo.admin.patch.Patch;
|
||||
@@ -48,11 +50,7 @@ import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect;
|
||||
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect;
|
||||
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.LogUtil;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.alfresco.util.schemadump.Main;
|
||||
@@ -78,7 +76,6 @@ import org.hibernate.dialect.OracleDialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.ActionQueue;
|
||||
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -194,6 +191,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
|
||||
private static Log logger = LogFactory.getLog(SchemaBootstrap.class);
|
||||
|
||||
private DataSource dataSource;
|
||||
private LocalSessionFactoryBean localSessionFactory;
|
||||
private String schemaOuputFilename;
|
||||
private boolean updateSchema;
|
||||
@@ -222,6 +220,11 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
globalProperties = new Properties();
|
||||
}
|
||||
|
||||
public void setDataSource(DataSource dataSource)
|
||||
{
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory)
|
||||
{
|
||||
this.localSessionFactory = localSessionFactory;
|
||||
@@ -402,25 +405,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
this.globalProperties = globalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to generate a schema creation SQL script from the given Hibernate
|
||||
* configuration.
|
||||
*/
|
||||
private static void dumpSchemaCreate(Configuration cfg, File schemaOutputFile)
|
||||
{
|
||||
// if the file exists, delete it
|
||||
if (schemaOutputFile.exists())
|
||||
{
|
||||
schemaOutputFile.delete();
|
||||
}
|
||||
SchemaExport schemaExport = new SchemaExport(cfg)
|
||||
.setFormat(true)
|
||||
.setHaltOnError(true)
|
||||
.setOutputFile(schemaOutputFile.getAbsolutePath())
|
||||
.setDelimiter(";");
|
||||
schemaExport.execute(false, false, false, true);
|
||||
}
|
||||
|
||||
private SessionFactory getSessionFactory()
|
||||
{
|
||||
return (SessionFactory) localSessionFactory.getObject();
|
||||
@@ -765,9 +749,9 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
else
|
||||
{
|
||||
// Check for scripts that must have been run
|
||||
checkSchemaPatchScripts(cfg, session, connection, validateUpdateScriptPatches, false);
|
||||
checkSchemaPatchScripts(cfg, connection, validateUpdateScriptPatches, false);
|
||||
// Execute any pre-auto-update scripts
|
||||
checkSchemaPatchScripts(cfg, session, connection, preUpdateScriptPatches, true);
|
||||
checkSchemaPatchScripts(cfg, connection, preUpdateScriptPatches, true);
|
||||
|
||||
// Build and execute changes generated by Hibernate
|
||||
File tempFile = null;
|
||||
@@ -801,7 +785,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
}
|
||||
|
||||
// Execute any post-auto-update scripts
|
||||
checkSchemaPatchScripts(cfg, session, connection, postUpdateScriptPatches, true);
|
||||
checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, true);
|
||||
}
|
||||
|
||||
return create;
|
||||
@@ -812,7 +796,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
*/
|
||||
private void checkSchemaPatchScripts(
|
||||
Configuration cfg,
|
||||
Session session,
|
||||
Connection connection,
|
||||
List<SchemaUpgradeScriptPatch> scriptPatches,
|
||||
boolean apply) throws Exception
|
||||
@@ -952,7 +935,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
{
|
||||
// Dump the normalized, pre-upgrade Alfresco schema. We keep the file for later reporting.
|
||||
xmlPreSchemaOutputFile = dumpSchema(
|
||||
connection,
|
||||
this.dialect,
|
||||
TempFileProvider.createTempFile(
|
||||
"AlfrescoSchema-" + this.dialect.getClass().getSimpleName() + "-",
|
||||
@@ -1351,7 +1333,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
try
|
||||
{
|
||||
// make sure that we AUTO-COMMIT
|
||||
connection = session.connection();
|
||||
connection = dataSource.getConnection();
|
||||
connection.setAutoCommit(true);
|
||||
|
||||
Configuration cfg = localSessionFactory.getConfiguration();
|
||||
@@ -1424,9 +1406,9 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
if (! createdSchema)
|
||||
{
|
||||
// verify that all patches have been applied correctly
|
||||
checkSchemaPatchScripts(cfg, session, connection, validateUpdateScriptPatches, false); // check scripts
|
||||
checkSchemaPatchScripts(cfg, session, connection, preUpdateScriptPatches, false); // check scripts
|
||||
checkSchemaPatchScripts(cfg, session, connection, postUpdateScriptPatches, false); // check scripts
|
||||
checkSchemaPatchScripts(cfg, connection, validateUpdateScriptPatches, false); // check scripts
|
||||
checkSchemaPatchScripts(cfg, connection, preUpdateScriptPatches, false); // check scripts
|
||||
checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, false); // check scripts
|
||||
}
|
||||
|
||||
if (executedStatements != null)
|
||||
@@ -1440,7 +1422,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
{
|
||||
// Dump the normalized, post-upgrade Alfresco schema.
|
||||
File xmlPostSchemaOutputFile = dumpSchema(
|
||||
connection,
|
||||
this.dialect,
|
||||
TempFileProvider.createTempFile(
|
||||
"AlfrescoSchema-" + this.dialect.getClass().getSimpleName() + "-",
|
||||
@@ -1479,7 +1460,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
// We have been forced to stop, so we do one last dump of the schema and throw an exception to
|
||||
// escape further startup procedures
|
||||
File xmlStopSchemaOutputFile = dumpSchema(
|
||||
connection,
|
||||
this.dialect,
|
||||
TempFileProvider.createTempFile(
|
||||
"AlfrescoSchema-" + this.dialect.getClass().getSimpleName() + "-",
|
||||
@@ -1538,12 +1518,12 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
/**
|
||||
* @return Returns the file that was written to or <tt>null</tt> if it failed
|
||||
*/
|
||||
private File dumpSchema(Connection connection, Dialect dialect, String fileName, String err)
|
||||
private File dumpSchema(Dialect dialect, String fileName, String err)
|
||||
{
|
||||
File xmlSchemaOutputFile = new File(fileName);
|
||||
try
|
||||
{
|
||||
Main xmlSchemaOutputMain = new Main(connection, dialect);
|
||||
Main xmlSchemaOutputMain = new Main(dataSource, dialect);
|
||||
xmlSchemaOutputMain.execute(xmlSchemaOutputFile);
|
||||
}
|
||||
catch (Throwable e)
|
||||
@@ -1647,94 +1627,4 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String DIR_SCHEMAS = "schemas";
|
||||
/**
|
||||
* Dump a set of creation files for all known Hibernate dialects. These will be
|
||||
* dumped into the default temporary location in a subdirectory named <b>schemas</b>.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int exitCode = 0;
|
||||
try
|
||||
{
|
||||
exitCode = dumpDialects(args);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
LogUtil.error(logger, e, "SchemaBootstrap script dump failed");
|
||||
exitCode = 1;
|
||||
}
|
||||
// We can exit
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
private static int dumpDialects(String[] dialectClassNames)
|
||||
{
|
||||
if (dialectClassNames.length == 0)
|
||||
{
|
||||
System.out.println(
|
||||
"\n" +
|
||||
" ERROR: A list of fully qualified class names is required");
|
||||
return 1;
|
||||
}
|
||||
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
SchemaBootstrap schemaBootstrap = (SchemaBootstrap) ctx.getBean("schemaBootstrap");
|
||||
LocalSessionFactoryBean localSessionFactoryBean = schemaBootstrap.getLocalSessionFactory();
|
||||
Configuration configuration = localSessionFactoryBean.getConfiguration();
|
||||
|
||||
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||
DescriptorService descriptorService = serviceRegistry.getDescriptorService();
|
||||
Descriptor descriptor = descriptorService.getServerDescriptor();
|
||||
|
||||
File tempDir = TempFileProvider.getTempDir();
|
||||
File schemasDir = new File(tempDir, DIR_SCHEMAS);
|
||||
if (!schemasDir.exists())
|
||||
{
|
||||
schemasDir.mkdir();
|
||||
}
|
||||
File dumpDir = new File(schemasDir, descriptor.getVersion());
|
||||
if (!dumpDir.exists())
|
||||
{
|
||||
dumpDir.mkdir();
|
||||
}
|
||||
for (String dialectClassName : dialectClassNames)
|
||||
{
|
||||
Class dialectClazz = null;
|
||||
try
|
||||
{
|
||||
dialectClazz = Class.forName(dialectClassName);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
System.out.println(
|
||||
"\n" +
|
||||
" ERROR: Class not found: " + dialectClassName);
|
||||
continue;
|
||||
}
|
||||
if (!Dialect.class.isAssignableFrom(dialectClazz))
|
||||
{
|
||||
System.out.println(
|
||||
"\n" +
|
||||
" ERROR: The class name is not a valid dialect: " + dialectClassName);
|
||||
continue;
|
||||
}
|
||||
dumpDialectScript(configuration, dialectClazz, dumpDir);
|
||||
}
|
||||
// Done
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void dumpDialectScript(Configuration configuration, Class dialectClazz, File directory)
|
||||
{
|
||||
// Set the dialect
|
||||
configuration.setProperty("hibernate.dialect", dialectClazz.getName());
|
||||
|
||||
// First dump the dialect's schema
|
||||
String filename = "default-schema-create-" + dialectClazz.getName() + ".sql";
|
||||
File dumpFile = new File(directory, filename);
|
||||
|
||||
// Write the file
|
||||
SchemaBootstrap.dumpSchemaCreate(configuration, dumpFile);
|
||||
}
|
||||
}
|
||||
|
@@ -138,6 +138,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
public static final QName ASSOC_ASPECT_CHILD_ASSOC = QName.createQName(NAMESPACE, "aspect-child-assoc");
|
||||
public static final QName ASSOC_ASPECT_NORMAL_ASSOC = QName.createQName(NAMESPACE, "aspect-normal-assoc");
|
||||
|
||||
public static final QName ASPECT_WITH_ASSOCIATIONS_EXTRA = QName.createQName(NAMESPACE, "withAssociationsExtra");
|
||||
public static final QName ASSOC_ASPECT_CHILD_ASSOC_01 = QName.createQName(NAMESPACE, "aspect-child-assoc-01");
|
||||
public static final QName ASSOC_ASPECT_CHILD_ASSOC_02 = QName.createQName(NAMESPACE, "aspect-child-assoc-02");
|
||||
public static final QName ASSOC_ASPECT_NORMAL_ASSOC_01 = QName.createQName(NAMESPACE, "aspect-normal-assoc-01");
|
||||
public static final QName ASSOC_ASPECT_NORMAL_ASSOC_02 = QName.createQName(NAMESPACE, "aspect-normal-assoc-02");
|
||||
|
||||
public static final QName TYPE_QNAME_TEST_MULTIPLE_TESTER = QName.createQName(NAMESPACE, "multiple-tester");
|
||||
public static final QName PROP_QNAME_STRING_PROP_SINGLE = QName.createQName(NAMESPACE, "stringprop-single");
|
||||
public static final QName PROP_QNAME_STRING_PROP_MULTIPLE = QName.createQName(NAMESPACE, "stringprop-multiple");
|
||||
@@ -790,6 +796,24 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
0, nodeService.getChildAssocs(sourceNodeRef).size());
|
||||
assertEquals("Expected exactly zero target",
|
||||
0, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size());
|
||||
|
||||
// Force different cleanup queries:
|
||||
// ALF-5308: SQL error when changing name for record / folder with dispostion schedule applied
|
||||
nodeService.addAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS_EXTRA, null);
|
||||
// Make the associations
|
||||
nodeService.addChild(
|
||||
sourceNodeRef,
|
||||
targetNodeRef,
|
||||
ASSOC_ASPECT_CHILD_ASSOC_01,
|
||||
QName.createQName(NAMESPACE, "aspect-child-01"));
|
||||
nodeService.addChild(
|
||||
sourceNodeRef,
|
||||
targetNodeRef,
|
||||
ASSOC_ASPECT_CHILD_ASSOC_02,
|
||||
QName.createQName(NAMESPACE, "aspect-child-02"));
|
||||
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ASSOC_ASPECT_NORMAL_ASSOC_01);
|
||||
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ASSOC_ASPECT_NORMAL_ASSOC_02);
|
||||
nodeService.removeAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS_EXTRA);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -380,6 +380,56 @@
|
||||
</associations>
|
||||
</aspect>
|
||||
|
||||
<aspect name="test:withAssociationsExtra">
|
||||
<title>Aspect with Associations</title>
|
||||
<associations>
|
||||
<child-association name="test:aspect-child-assoc-01">
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</source>
|
||||
<target>
|
||||
<class>sys:base</class>
|
||||
<mandatory>true</mandatory>
|
||||
<many>true</many>
|
||||
</target>
|
||||
</child-association>
|
||||
<child-association name="test:aspect-child-assoc-02">
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</source>
|
||||
<target>
|
||||
<class>sys:base</class>
|
||||
<mandatory>true</mandatory>
|
||||
<many>true</many>
|
||||
</target>
|
||||
</child-association>
|
||||
<association name="test:aspect-normal-assoc-01">
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</source>
|
||||
<target>
|
||||
<class>sys:base</class>
|
||||
<mandatory>true</mandatory>
|
||||
<many>true</many>
|
||||
</target>
|
||||
</association>
|
||||
<association name="test:aspect-normal-assoc-02">
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</source>
|
||||
<target>
|
||||
<class>sys:base</class>
|
||||
<mandatory>true</mandatory>
|
||||
<many>true</many>
|
||||
</target>
|
||||
</association>
|
||||
</associations>
|
||||
</aspect>
|
||||
|
||||
<!-- ano1 aspect - happens to be the same name as a child assoc name -->
|
||||
<aspect name="test:aspect-child-assoc">
|
||||
<title>Aspect ANO1</title>
|
||||
|
@@ -41,6 +41,7 @@ import javax.xml.transform.sax.SAXTransformerFactory;
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.Oracle8iDialect;
|
||||
import org.hibernate.dialect.TypeNames;
|
||||
@@ -67,8 +68,8 @@ public class Main
|
||||
/** Should we scale down string field widths (assuming 4 bytes to one character?). */
|
||||
private boolean scaleCharacters;
|
||||
|
||||
/** The JDBC connection. */
|
||||
private Connection con;
|
||||
/** The JDBC DataSource. */
|
||||
private DataSource dataSource;
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
@@ -92,15 +93,13 @@ public class Main
|
||||
/**
|
||||
* Creates a new instance of this tool by starting up a full context.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Main(final String contextPath) throws Exception
|
||||
{
|
||||
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]
|
||||
{
|
||||
"file:" + contextPath
|
||||
});
|
||||
final DataSource datasource = (DataSource) context.getBean("dataSource");
|
||||
this.con = datasource.getConnection();
|
||||
this.dataSource = (DataSource) context.getBean("dataSource");
|
||||
|
||||
// Use Java reflection to bypass accessibility rules and get hold of hibernate's type mapping!
|
||||
final Properties hibProps = (Properties) context.getBean("hibernateConfigProperties");
|
||||
@@ -116,9 +115,9 @@ public class Main
|
||||
* @param connection the database connection to use for metadata queries
|
||||
* @param dialect the Hibernate dialect
|
||||
*/
|
||||
public Main(final Connection connection, final Dialect dialect) throws Exception
|
||||
public Main(final DataSource dataSource, final Dialect dialect) throws Exception
|
||||
{
|
||||
this.con = connection;
|
||||
this.dataSource = dataSource;
|
||||
|
||||
// Initialize
|
||||
init(dialect);
|
||||
@@ -163,7 +162,19 @@ public class Main
|
||||
*/
|
||||
public void execute(File outputFile) throws Exception
|
||||
{
|
||||
final NamedElementCollection result = execute();
|
||||
PropertyCheck.mandatory(this, "dataSource", dataSource);
|
||||
// Get a Connection
|
||||
Connection connection = dataSource.getConnection();
|
||||
NamedElementCollection result = null;
|
||||
try
|
||||
{
|
||||
connection.setAutoCommit(false);
|
||||
result = execute(connection);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { connection.close(); } catch (Throwable e) {}
|
||||
}
|
||||
|
||||
// Set up a SAX TransformerHandler for outputting XML
|
||||
final SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance();
|
||||
@@ -190,11 +201,11 @@ public class Main
|
||||
*
|
||||
* @return Returns the named XML elements
|
||||
*/
|
||||
public NamedElementCollection execute() throws Exception
|
||||
private NamedElementCollection execute(Connection con) throws Exception
|
||||
{
|
||||
final NamedElementCollection schemaCol = new NamedElementCollection("schema", "table");
|
||||
|
||||
final DatabaseMetaData dbmd = this.con.getMetaData();
|
||||
final DatabaseMetaData dbmd = con.getMetaData();
|
||||
|
||||
// Assume that if there are schemas, we want the one named after the connection user or the one called "dbo" (MS
|
||||
// SQL hack)
|
||||
@@ -398,19 +409,6 @@ public class Main
|
||||
this.elementName = elementName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an attribute.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void addAttribute(final String name, final String value)
|
||||
{
|
||||
this.attributes.addAttribute("", "", name, "CDATA", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a named element.
|
||||
*
|
||||
|
Reference in New Issue
Block a user