diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql index 053fc5f1d4..021df851c3 100644 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql +++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AvmTables.sql @@ -119,7 +119,7 @@ tag varchar(255), description text, primary key (id), - unique (version_id, avm_store_id) + constraint unique index idx_avm_vr_uq (avm_store_id, version_id) ) ENGINE=InnoDB; alter table avm_aspects @@ -233,8 +233,6 @@ ALTER TABLE avm_store_properties ADD CONSTRAINT fk_avm_sprop_qname FOREIGN KEY ( CREATE INDEX idx_avm_hl_revpk ON avm_history_links (descendent, ancestor); -CREATE INDEX idx_avm_vr_revuq ON avm_version_roots (avm_store_id, version_id); - CREATE INDEX idx_avm_ce_lc_name ON avm_child_entries (lc_name, parent_id); -- diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml index ef8d5020b6..b9ff7c57fa 100644 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml +++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-AVM.xml @@ -715,12 +715,6 @@ - - - version_id - avm_store_id - - version_id @@ -736,7 +730,7 @@ root_id - + avm_store_id version_id diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql index 2b6dfb3d43..c4c96d7042 100644 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql +++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AvmTables.sql @@ -122,10 +122,14 @@ root_id INT8 not null, tag varchar(255), description VARCHAR(1024), - primary key (id), - unique (version_id, avm_store_id) + primary key (id) ); - + + create unique index idx_avm_vr_uq on avm_version_roots (avm_store_id, version_id); + alter table avm_version_roots + add constraint idx_avm_vr_uq + unique using index idx_avm_vr_uq; + alter table avm_aspects add constraint fk_avm_nasp_n foreign key (node_id) @@ -237,8 +241,6 @@ ALTER TABLE avm_store_properties ADD CONSTRAINT fk_avm_sprop_qname FOREIGN KEY ( CREATE INDEX idx_avm_hl_revpk ON avm_history_links (descendent, ancestor); -CREATE INDEX idx_avm_vr_revuq ON avm_version_roots (avm_store_id, version_id); - CREATE INDEX idx_avm_ce_lc_name ON avm_child_entries (lc_name, parent_id); -- diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml index 8e23e6fbe2..614063e56b 100644 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml +++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-AVM.xml @@ -726,12 +726,6 @@ - - - version_id - avm_store_id - - root_id @@ -742,7 +736,7 @@ avm_store_id - + avm_store_id version_id diff --git a/config/alfresco/dbscripts/db-schema-context.xml b/config/alfresco/dbscripts/db-schema-context.xml index ce7a3b419e..462a3036ab 100644 --- a/config/alfresco/dbscripts/db-schema-context.xml +++ b/config/alfresco/dbscripts/db-schema-context.xml @@ -106,6 +106,7 @@ + diff --git a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql new file mode 100644 index 0000000000..5a6c05cce8 --- /dev/null +++ b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/drop-AVM-index.sql @@ -0,0 +1,26 @@ +-- +-- Title: DROP unused IDX_AVM_VR_REVUQ index +-- Database: InnoDB +-- Since: V4.2 Schema 6031 +-- Author: Alex Mukha +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- +-- ALF-19487 : ORACLE: AVM: Schema difference is present after upgrade from 3.4.13/4.0.2/4.1.5 + +DROP INDEX idx_avm_vr_revuq ON avm_version_roots; +DROP INDEX version_id ON avm_version_roots; +ALTER TABLE avm_version_roots ADD CONSTRAINT UNIQUE INDEX idx_avm_vr_uq (avm_store_id, version_id); + +-- +-- Record script finish +-- + +DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.2-drop-AVM-index'; +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-V4.2-drop-AVM-index', 'Manually executed script to drop unnecessary index', + 0, 6031, -1, 6032, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' + ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql new file mode 100644 index 0000000000..a9fae9afd0 --- /dev/null +++ b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/drop-AVM-index.sql @@ -0,0 +1,27 @@ +-- +-- Title: DROP unused IDX_AVM_VR_REVUQ index +-- Database: PostgreSQL +-- Since: V4.2 Schema 6031 +-- Author: Alex Mukha +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- +-- ALF-19487 : ORACLE: AVM: Schema difference is present after upgrade from 3.4.13/4.0.2/4.1.5 + +DROP INDEX idx_avm_vr_revuq; +ALTER TABLE avm_version_roots DROP CONSTRAINT avm_version_roots_version_id_avm_store_id_key; +CREATE UNIQUE INDEX idx_avm_vr_uq ON avm_version_roots (avm_store_id, version_id); +ALTER TABLE avm_version_roots ADD CONSTRAINT idx_avm_vr_uq UNIQUE USING INDEX idx_avm_vr_uq; + +-- +-- Record script finish +-- + +DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.2-drop-AVM-index'; +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-V4.2-drop-AVM-index', 'Manually executed script to drop unnecessary index', + 0, 6031, -1, 6032, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed' + ); \ No newline at end of file diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index cee1f04eec..e14fa49035 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -3619,4 +3619,15 @@ classpath:alfresco/dbscripts/upgrade/4.1/${db.script.dialect}/fix-AVM-seqs-order.sql + + + + + 0 + 6031 + 6032 + + classpath:alfresco/dbscripts/upgrade/4.2/${db.script.dialect}/drop-AVM-index.sql + + diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index b78abf8fcd..59db733e05 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -23,4 +23,4 @@ version.build=r@scm-revision@-b@build-number@ # Schema number -version.schema=6031 +version.schema=6032