diff --git a/ccm-ldn-navigation/sql/ccm-ldn-navigation/upgrade/default/6.6.1-6.6.2/remove_legacy_entries.sql b/ccm-ldn-navigation/sql/ccm-ldn-navigation/upgrade/default/6.6.1-6.6.2/remove_legacy_entries.sql index a589f3cc3..f2f14f79f 100644 --- a/ccm-ldn-navigation/sql/ccm-ldn-navigation/upgrade/default/6.6.1-6.6.2/remove_legacy_entries.sql +++ b/ccm-ldn-navigation/sql/ccm-ldn-navigation/upgrade/default/6.6.1-6.6.2/remove_legacy_entries.sql @@ -21,36 +21,111 @@ -- entries in tables apm_package_types are no longer needed. +-- in case of navigation there may be several application instances! + +-- delete from object_context all entries referring to node_id in site_nodes +delete from object_context + where object_id in + (select node_id from site_nodes object_id where object_id in + ( select package_id from applications where application_type_id = + (select application_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') + ) + ); + +-- delete from acs_objects all entries referring to node_id in site_nodes +alter table site_nodes drop constraint site_nodes_node_id_f_n1m2y ; +delete from acs_objects + where object_id in + (select node_id from site_nodes where object_id in + ( select package_id from applications where application_type_id = + (select application_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') + ) + ); + +-- delete all entries in site_nodes referring to a navigation instance +delete from site_nodes + where object_id in + (select package_id from applications where application_type_id = + (select application_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') + ); +alter table site_nodes add constraint site_nodes_node_id_f_n1m2y + FOREIGN KEY (node_id) + REFERENCES acs_objects (object_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION ; + + + +-- delete from object_context all entries referring to package_id in apm_packages +delete from object_context + where object_id in + (select package_id from apm_packages where package_type_id = + (select package_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') + ); + +-- delete from acs_objects all entries referring to package_id in apm_packages +alter table apm_packages drop constraint apm_package_package_id_f_46may ; +alter table applications drop constraint application_package_id_f_cdaho ; +delete from acs_objects + where object_id in + (select package_id from apm_packages where package_type_id = + (select package_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') + ); + +-- delete all entries for navigation instances in apm_packages +-- identified by package_type_id in application_types +delete from apm_packages + where package_type_id = + (select package_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') ; + +-- there seem to be no intries for a apm_packages_types entry (row) in +-- acs_objects or object_congtext! + +-- delete all entries for navigation in apm_package_types identified by +-- package_type_id in application_types +alter table application_types drop constraint applica_typ_pac_typ_id_f_v80ma ; +delete from apm_package_types + where package_type_id = + (select package_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') ; + + +-- set package_id to null for all entries referring to a navigation instance +-- (indicating a new legacy free application) update applications set package_id = null - where title like 'Navigation Control Center' ; - -delete from site_nodes - where url like '/navigation/' ; - -delete from apm_packages - where pretty_name like 'Navigation' ; - + where application_type_id = + (select application_type_id from application_types + where object_type + like 'com.arsdigita.london.navigation.Navigation') ; +-- set package_id to null for all entries referring to a navigation instance +-- (indicating a new legacy free application) update application_types set package_type_id = null where object_type like 'com.arsdigita.london.navigation.Navigation' ; -delete from apm_package_types - where package_key like 'navigation' ; - -delete from object_context - where object_id = (select acs_objects.object_id from acs_objects - where acs_objects.object_type - like '%com.arsdigita.kernel%' - AND acs_objects.display_name like '/navigation/') ; - -delete from object_context - where object_id = (select acs_objects.object_id from acs_objects - where acs_objects.object_type - like '%com.arsdigita.kernel%' - AND acs_objects.display_name like 'Navigation') ; - -delete from acs_objects - where object_type like '%com.arsdigita.kernel%' - AND display_name like '%avigatio%' ; +alter table application_types add constraint applica_typ_pac_typ_id_f_v80ma + FOREIGN KEY (package_type_id) + REFERENCES apm_package_types (package_type_id) + MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ; +alter table applications add constraint application_package_id_f_cdaho + FOREIGN KEY (package_id) + REFERENCES apm_packages (package_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION ; +alter table apm_packages add constraint apm_package_package_id_f_46may + FOREIGN KEY (package_id) + REFERENCES acs_objects (object_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION ;