Fix/db refactoring rename (#2365)

* Refactor datbase - renaming

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>

* Final refactoring

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-04-25 16:08:23 +03:00
committed by GitHub
parent 4714f5edf2
commit ffc550fcc7
28 changed files with 335 additions and 85 deletions

View File

@@ -0,0 +1,73 @@
-- rename tables
alter table sp_base_software_module rename to sp_software_module;
alter table sp_distributionset_tag rename to sp_distribution_set_tag;
alter table sp_ds_dstag rename to sp_ds_tag;
alter table sp_ds_module rename to sp_ds_sm;
alter table sp_rolloutgroup rename to sp_rollout_group;
alter table sp_rollouttargetgroup rename to sp_rollout_target_group;
alter table sp_sw_metadata rename to sp_sm_metadata;
alter table sp_target_type_ds_type_relation rename to sp_target_type_ds_type;
-- rename columns
alter table sp_action rename column rolloutgroup to rollout_group;
alter table sp_action_status_messages rename column action_status_id to action_status;
alter table sp_distribution_set rename column ds_id to ds_type;
alter table sp_ds_sm rename column module_id to sm_id;
alter table sp_ds_metadata rename column ds_id to ds;
alter table sp_ds_tag rename column TAG to tag;
alter table sp_rollout_group rename column parent_id to parent;
alter table sp_rollout_target_group rename column target_id to target;
alter table sp_rollout_target_group rename column rolloutgroup_id to rollout_group;
alter table sp_sm_metadata rename column sw_id to sm;
alter table sp_software_module rename column module_type to sm_type;
alter table sp_target_attributes rename column target_id to target;
alter table sp_target_conf_status rename column target_id to target;
alter table sp_target_metadata rename column target_id to target;
-- rename constraints
alter table sp_action rename constraint fk_action_ds to fk_action_distribution_set;
alter table sp_action rename constraint fk_action_rolloutgroup to fk_action_rollout_group;
alter table sp_action rename constraint fk_targ_act_hist_targ to fk_action_target;
alter table sp_action_status rename constraint fk_act_stat_action to fk_action_status_action;
alter table sp_action_status_messages rename constraint fk_stat_msg_act_stat to fk_action_status_messages_action_status;
alter table sp_artifact rename constraint fk_assigned_sm to fk_artifact_software_module;
alter table sp_distribution_set rename constraint uk_distrib_set to uk_distribution_set;
alter table sp_distribution_set rename constraint fk_ds_dstype_ds to fk_distribution_set_ds_type;
alter table sp_distribution_set_tag rename constraint uk_ds_tag to uk_distribution_set_tag;
alter table sp_distribution_set_type rename constraint uk_dst_key to uk_distribution_set_type_type_key;
alter table sp_distribution_set_type rename constraint uk_dst_name to uk_distribution_set_type_name;
alter table sp_ds_metadata rename constraint fk_metadata_ds to fk_ds_metadata_ds;
alter table sp_ds_sm rename constraint fk_ds_module_ds to fk_ds_sm_ds_id;
alter table sp_ds_sm rename constraint fk_ds_module_module to fk_ds_sm_sm_id;
alter table sp_ds_tag rename constraint fk_ds_dstag_ds to fk_ds_tag_ds;
alter table sp_ds_tag rename constraint fk_ds_dstag_tag to fk_ds_tag_tag;
alter table sp_ds_type_element rename constraint fk_ds_type_element_element to fk_ds_type_element_distribution_set_type;
alter table sp_ds_type_element rename constraint fk_ds_type_element_smtype to fk_ds_type_element_software_module_type;
alter table sp_rollout rename constraint fk_rollout_ds to fk_rollout_distribution_set;
alter table sp_rollout_group rename constraint uk_rolloutgroup to uk_rollout_group;
alter table sp_rollout_group rename constraint fk_rolloutgroup_rollout to fk_rollout_group_rollout;
alter table sp_rollout_target_group rename constraint fk_rollouttargetgroup_rolloutgroup to fk_rollout_target_group_rollout_group;
alter table sp_sm_metadata rename constraint fk_metadata_sw to fk_sm_metadata_sm;
alter table sp_software_module rename constraint uk_base_sw_mod to uk_software_module;
alter table sp_software_module rename constraint fk_module_type to fk_software_module_sm_type;
alter table sp_software_module_type rename constraint uk_smt_type_key to uk_software_module_type_type_key;
alter table sp_software_module_type rename constraint uk_smt_name to uk_software_module_type_name;
alter table sp_rollout_target_group rename constraint fk_rollouttargetgroup_target to fk_rollout_target_group_target;
alter table sp_target rename constraint uk_tenant_controller_id to uk_target_controller_id;
alter table sp_target_attributes rename constraint fk_targ_attrib_target to fk_target_attributes_target;
alter table sp_target_conf_status rename constraint fk_target_auto_conf to fk_target_conf_status_target;
alter table sp_target_filter_query rename constraint uk_tenant_custom_filter_name to uk_target_filter_query;
alter table sp_target_filter_query rename constraint fk_filter_auto_assign_ds to fk_target_filter_query_auto_assign_distribution_set;
alter table sp_target_metadata rename constraint fk_metadata_target to fk_target_metadata_target;
alter table sp_target_tag rename constraint uk_targ_tag to uk_target_tag;
alter table sp_target_target_tag rename constraint fk_targ_targtag_target to fk_target_target_tag_target;
alter table sp_target_target_tag rename constraint fk_targ_targtag_tag to fk_target_target_tag_tag;
alter table sp_target_type rename constraint uk_target_type_name to uk_target_name;
alter table sp_target_type_ds_type rename constraint fk_target_type_relation_target_type to fk_target_type_ds_type_target_type;
alter table sp_target_type_ds_type rename constraint fk_target_type_relation_ds_type to fk_target_type_ds_type_distribution_set_type;
alter table sp_tenant rename constraint uk_tenantmd_tenant to uk_tenant;
alter table sp_tenant rename constraint fk_tenant_md_default_ds_type to fk_sp_tenant_default_ds_type;
alter table sp_tenant_configuration rename constraint uk_tenant_key to uk_tenant_configuration;
-- rename indexes
alter index sp_idx_action_status_msgs_01 rename to fk_action_status_messages_action_status;
alter index sp_idx_base_sw_module_prim rename to sp_idx_software_module_prim;
alter index sp_idx_base_sw_module_01 rename to sp_idx_software_module_01;
alter index sp_idx_base_sw_module_02 rename to sp_idx_software_module_02;

View File

@@ -0,0 +1,63 @@
-- rename tables
alter table sp_base_software_module rename to sp_software_module;
alter table sp_distributionset_tag rename to sp_distribution_set_tag;
alter table sp_ds_dstag rename to sp_ds_tag;
alter table sp_ds_module rename to sp_ds_sm;
alter table sp_rolloutgroup rename to sp_rollout_group;
alter table sp_rollouttargetgroup rename to sp_rollout_target_group;
alter table sp_sw_metadata rename to sp_sm_metadata;
alter table sp_target_type_ds_type_relation rename to sp_target_type_ds_type;
-- rename columns
alter table sp_action rename column rolloutgroup to rollout_group;
alter table sp_action_status_messages rename column action_status_id to action_status;
alter table sp_distribution_set rename column ds_id to ds_type;
alter table sp_ds_sm rename column module_id to sm_id;
alter table sp_ds_metadata rename column ds_id to ds;
alter table sp_ds_tag rename column TAG to tag;
alter table sp_rollout_group rename column parent_id to parent;
alter table sp_rollout_target_group rename column target_id to target;
alter table sp_rollout_target_group rename column rolloutgroup_id to rollout_group;
alter table sp_sm_metadata rename column sw_id to sm;
alter table sp_software_module rename column module_type to sm_type;
alter table sp_target_attributes rename column target_id to target;
alter table sp_target_conf_status rename column target_id to target;
alter table sp_target_metadata rename column target_id to target;
-- rename constraints
-- rename indexes
alter table sp_action rename index fk_action_ds to fk_action_distribution_set;
alter table sp_action rename index fk_action_rolloutgroup to fk_action_rollout_group;
alter table sp_action rename index fk_targ_act_hist_targ to fk_action_target;
alter table sp_action_status rename index fk_act_stat_action to fk_action_status_action;
alter table sp_action_status_messages rename index sp_idx_action_status_msgs_01 to fk_action_status_messages_action_status;
alter table sp_artifact rename index fk_assigned_sm to fk_artifact_software_module;
alter table sp_distribution_set rename index uk_distrib_set to uk_distribution_set;
alter table sp_distribution_set rename index fk_ds_dstype_ds to fk_distribution_set_ds_type;
alter table sp_distribution_set_tag rename index uk_ds_tag to uk_distribution_set_tag;
alter table sp_distribution_set_type rename index uk_dst_key to uk_distribution_set_type_type_key;
alter table sp_distribution_set_type rename index uk_dst_name to uk_distribution_set_type_name;
alter table sp_ds_sm rename index fk_ds_module_module to fk_ds_sm_sm_id;
alter table sp_ds_tag rename index fk_ds_dstag_tag to fk_ds_tag_tag;
alter table sp_ds_type_element rename index fk_ds_type_element_smtype to fk_ds_type_element_software_module_type;
alter table sp_rollout rename index fk_rollout_ds to fk_rollout_distribution_set;
alter table sp_rollout_group rename index uk_rolloutgroup to uk_rollout_group;
alter table sp_rollout_group rename index fk_rolloutgroup_rollout to fk_rollout_group_rollout;
alter table sp_rollout_group rename index fk_rolloutgroup_rolloutgroup to sp_idx_rollout_group_parent;
alter table sp_rollout_target_group rename index fk_rollouttargetgroup_target to fk_rollout_target_group_target;
alter table sp_sm_metadata rename index fk_metadata_sw to fk_sm_metadata_sm;
alter table sp_software_module rename index uk_base_sw_mod to uk_software_module;
alter table sp_software_module_type rename index uk_smt_type_key to uk_software_module_type_type_key;
alter table sp_software_module_type rename index uk_smt_name to uk_software_module_type_name;
alter table sp_software_module rename index sp_idx_base_sw_module_prim to sp_idx_software_module_prim;
alter table sp_software_module rename index sp_idx_base_sw_module_01 to sp_idx_software_module_01;
alter table sp_software_module rename index sp_idx_base_sw_module_02 to sp_idx_software_module_02;
alter table sp_target rename index uk_tenant_controller_id to uk_target_controller_id;
alter table sp_target_conf_status rename index fk_target_auto_conf to fk_target_conf_status_target;
alter table sp_target_filter_query rename index uk_tenant_custom_filter_name to uk_target_filter_query;
alter table sp_target_filter_query rename index fk_filter_auto_assign_ds to fk_target_filter_query_auto_assign_distribution_set;
alter table sp_target_tag rename index uk_targ_tag to uk_target_tag;
alter table sp_target_target_tag rename index fk_targ_targtag_tag to fk_target_target_tag_tag;
alter table sp_target_type rename index uk_target_type_name to uk_target_name;
alter table sp_target_type_ds_type rename index fk_target_type_relation_ds_type to fk_target_type_ds_type_distribution_set_type;
alter table sp_tenant rename index uk_tenantmd_tenant to uk_tenant;
alter table sp_tenant rename index fk_tenant_md_default_ds_type to fk_tenant_default_ds_type;
alter table sp_tenant_configuration rename index uk_tenant_key to uk_tenant_configuration;

View File

@@ -0,0 +1,98 @@
-- rename tables
alter table sp_base_software_module rename to sp_software_module;
alter table sp_distributionset_tag rename to sp_distribution_set_tag;
alter table sp_ds_dstag rename to sp_ds_tag;
alter table sp_ds_module rename to sp_ds_sm;
alter table sp_rolloutgroup rename to sp_rollout_group;
alter table sp_rollouttargetgroup rename to sp_rollout_target_group;
alter table sp_sw_metadata rename to sp_sm_metadata;
alter table sp_target_type_ds_type_relation rename to sp_target_type_ds_type;
-- rename columns
alter table sp_action rename column rolloutgroup to rollout_group;
alter table sp_action_status_messages rename column action_status_id to action_status;
alter table sp_distribution_set rename column ds_id to ds_type;
alter table sp_ds_sm rename column module_id to sm_id;
alter table sp_ds_metadata rename column ds_id to ds;
alter table sp_rollout_group rename column parent_id to parent;
alter table sp_rollout_target_group rename column target_id to target;
alter table sp_rollout_target_group rename column rolloutgroup_id to rollout_group;
alter table sp_sm_metadata rename column sw_id to sm;
alter table sp_software_module rename column module_type to sm_type;
alter table sp_target_attributes rename column target_id to target;
alter table sp_target_conf_status rename column target_id to target;
alter table sp_target_metadata rename column target_id to target;
-- rename constraints
alter table sp_action rename constraint fk_action_ds to fk_action_distribution_set;
alter table sp_action rename constraint fk_action_rolloutgroup to fk_action_rollout_group;
alter table sp_action rename constraint fk_targ_act_hist_targ to fk_action_target;
alter table sp_action_status rename constraint fk_act_stat_action to fk_action_status_action;
alter table sp_action_status_messages rename constraint fk_stat_msg_act_stat to fk_action_status_messages_action_status;
alter table sp_artifact rename constraint fk_assigned_sm to fk_artifact_software_module;
alter table sp_distribution_set rename constraint uk_distrib_set_sp_distribution_set to uk_distribution_set;
alter table sp_distribution_set rename constraint fk_ds_dstype_ds to fk_distribution_set_ds_type;
alter table sp_distribution_set_tag rename constraint uk_ds_tag_sp_distributionset_tag to uk_distribution_set_tag;
alter table sp_distribution_set_type rename constraint uk_dst_key_sp_distribution_set_type to uk_distribution_set_type_type_key;
alter table sp_distribution_set_type rename constraint uk_dst_name_sp_distribution_set_type to uk_distribution_set_type_name;
alter table sp_ds_metadata rename constraint fk_metadata_ds to fk_ds_metadata_ds;
alter table sp_ds_sm rename constraint fk_ds_module_ds to fk_ds_sm_ds_id;
alter table sp_ds_sm rename constraint fk_ds_module_module to fk_ds_sm_sm_id;
alter table sp_ds_tag rename constraint fk_ds_dstag_ds to fk_ds_tag_ds;
alter table sp_ds_tag rename constraint fk_ds_dstag_tag to fk_ds_tag_tag;
alter table sp_ds_type_element rename constraint fk_ds_type_element_element to fk_ds_type_element_distribution_set_type;
alter table sp_ds_type_element rename constraint fk_ds_type_element_smtype to fk_ds_type_element_software_module_type;
alter table sp_rollout rename constraint fk_rollout_ds to fk_rollout_distribution_set;
alter table sp_rollout_group rename constraint uk_rolloutgroup_sp_rolloutgroup to uk_rollout_group;
alter table sp_rollout_group rename constraint fk_rolloutgroup_rollout to fk_rollout_group_rollout;
alter table sp_rollout_target_group rename constraint fk_rollouttargetgroup_rolloutgroup to fk_rollout_target_group_rollout_group;
alter table sp_rollout_target_group rename constraint fk_rollouttargetgroup_target to fk_rollout_target_group_target;
alter table sp_sm_metadata rename constraint fk_metadata_sw to fk_sm_metadata_sm;
alter table sp_software_module rename constraint uk_base_sw_mod_sp_base_software_module to uk_software_module;
alter table sp_software_module rename constraint fk_module_type to fk_software_module_sm_type;
alter table sp_software_module_type rename constraint uk_smt_type_key_sp_software_module_type to uk_software_module_type_type_key;
alter table sp_software_module_type rename constraint uk_smt_name_sp_software_module_type to uk_software_module_type_name;
alter table sp_target rename constraint uk_tenant_controller_id_sp_target to uk_target;
alter table sp_target_attributes rename constraint fk_targ_attrib_target to fk_target_attributes_target;
alter table sp_target_filter_query rename constraint uk_tenant_custom_filter_name_sp_target_filter_query to uk_target_filter_query;
alter table sp_target_filter_query rename constraint fk_filter_auto_assign_ds to fk_target_filter_query_auto_assign_distribution_set;
alter table sp_target_metadata rename constraint fk_metadata_target to fk_target_metadata_target;
alter table sp_target_tag rename constraint uk_targ_tag_sp_target_tag to uk_target_tag;
alter table sp_target_target_tag rename constraint fk_targ_targtag_target to fk_target_target_tag_target;
alter table sp_target_target_tag rename constraint fk_targ_targtag_tag to fk_target_target_tag_tag;
alter table sp_target_type rename constraint uk_target_type_name to uk_target_name;
alter table sp_target_type_ds_type rename constraint fk_target_type_relation_target_type to fk_target_type_ds_type_target_type;
alter table sp_target_type_ds_type rename constraint fk_target_type_relation_ds_type to fk_target_type_ds_type_distribution_set_type;
alter table sp_tenant rename constraint uk_tenantmd_tenant_sp_tenant to uk_tenant;
alter table sp_tenant rename constraint fk_tenant_md_default_ds_type to fk_sp_tenant_default_ds_type;
alter table sp_tenant_configuration rename constraint uk_tenant_key_sp_tenant_configuration to uk_tenant_configuration;
-- rename primary keys
alter table sp_action rename constraint pk_sp_action to pk_action;
alter table sp_action_status rename constraint pk_sp_action_status to pk_action_status;
alter table sp_artifact rename constraint pk_sp_artifact to pk_artifact;
alter table sp_software_module rename constraint pk_sp_base_software_module to pk_software_module;
alter table sp_distribution_set rename constraint pk_sp_distribution_set to pk_distribution_set;
alter table sp_distribution_set_type rename constraint pk_sp_distribution_set_type to pk_distribution_set_type;
alter table sp_distribution_set_tag rename constraint pk_sp_distributionset_tag to pk_distribution_set_tag;
alter table sp_ds_tag rename constraint pk_sp_ds_dstag to pk_ds_tag;
alter table sp_ds_metadata rename constraint pk_sp_ds_metadata to pk_ds_metadata;
alter table sp_ds_sm rename constraint pk_sp_ds_module to pk_ds_sm;
alter table sp_ds_type_element rename constraint pk_sp_ds_type_element to pk_ds_type_element;
alter table sp_rollout rename constraint pk_sp_rollout to pk_rollout;
alter table sp_rollout_group rename constraint pk_sp_rolloutgroup to pk_rollout_group;
alter table sp_rollout_target_group rename constraint pk_sp_rollouttargetgroup to pk_rollout_target_group;
alter table sp_software_module_type rename constraint pk_sp_software_module_type to pk_software_module_type;
alter table sp_sm_metadata rename constraint pk_sp_sw_metadata to pk_sm_metadata;
alter table sp_target rename constraint pk_sp_target to pk_target;
alter table sp_target_attributes rename constraint pk_sp_target_attributes to pk_target_attributes;
alter table sp_target_filter_query rename constraint pk_sp_target_filter_query to pk_target_filter_query;
alter table sp_target_metadata rename constraint pk_sp_target_metadata to pk_target_metadata;
alter table sp_target_tag rename constraint pk_sp_target_tag to pk_target_tag;
alter table sp_target_target_tag rename constraint pk_sp_target_target_tag to pk_target_target_tag;
alter table sp_tenant rename constraint pk_sp_tenant to pk_tenant;
alter table sp_tenant_configuration rename constraint pk_sp_tenant_configuration to pk_tenant_configuration;
-- rename indexes
alter index sp_idx_action_status_msgs_01_sp_action_status_messages rename to fk_action_status_messages_action_status;
alter index fk_rolloutgroup_rolloutgroup_sp_rolloutgroup rename to sp_idx_rollout_group_parent;
alter index sp_idx_rollouttargetgroup_target_id rename to sp_idx_rollout_target_group_target;
alter index sp_idx_base_sw_module_prim_sp_base_software_module rename to sp_idx_software_module_prim;
alter index sp_idx_base_sw_module_01_sp_base_software_module rename to sp_idx_software_module_01;
alter index sp_idx_base_sw_module_02_sp_base_software_module rename to sp_idx_software_module_02;