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:
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -21,7 +21,7 @@ There are two modes:
|
||||
**Note**: could also be configured using default flyway env properties
|
||||
|
||||
## Usage
|
||||
The module builds executable jar with all dependencies - _hawkbit-repository-jpa-init-\<revision\>-exec.jar_. It could be configured with environment properties and run as an executable jar:
|
||||
The module builds executable jar with all dependencies - _hawkbit-repository-jpa-init-\<revision\>.jar_. It could be configured with environment properties and run as an executable jar:
|
||||
```shell
|
||||
# sets the mode - default if validate
|
||||
export hawkbit_db_mode=migrate
|
||||
@@ -33,12 +33,12 @@ export hawkbit_db_username=root
|
||||
#export hawkbit_db_password=
|
||||
|
||||
# run executable jar
|
||||
java -jar target/hawkbit-repository-jpa-init-0-SNAPSHOT-exec.jar
|
||||
java -jar target/hawkbit-repository-jpa-init-0-SNAPSHOT.jar
|
||||
```
|
||||
|
||||
It could also be configured using system properties and run as a java main class:
|
||||
```shell
|
||||
java -classpath target/hawkbit-repository-jpa-init-0-SNAPSHOT-exec.jar \
|
||||
java -classpath target/hawkbit-repository-jpa-init-0-SNAPSHOT.jar \
|
||||
-Dhawkbit.db.mode=migrate \
|
||||
-Dhawkbit.db.url=jdbc:mariadb://localhost:3306/hawkbit \
|
||||
-Dhawkbit.db.username=root \
|
||||
|
||||
@@ -137,8 +137,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
||||
this.repositoryProperties = repositoryProperties;
|
||||
|
||||
final String isDeleted = isPostgreSql(properties) ? "false" : "0";
|
||||
countArtifactQuery = "SELECT COUNT(a.id) FROM sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countSoftwareModulesQuery = "select SUM(file_size) from sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countArtifactQuery = "SELECT COUNT(a.id) FROM sp_artifact a INNER JOIN sp_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countSoftwareModulesQuery = "select SUM(file_size) from sp_artifact a INNER JOIN sp_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
}
|
||||
|
||||
@Autowired(required = false) // it's not required on dmf/ddi only instances
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DistributionSetTypeElement implements Serializable {
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(
|
||||
name = "distribution_set_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_element"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_distribution_set_type"))
|
||||
private JpaDistributionSetType dsType;
|
||||
|
||||
@Getter
|
||||
@@ -56,7 +56,7 @@ public class DistributionSetTypeElement implements Serializable {
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(
|
||||
name = "software_module_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_smtype"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_software_module_type"))
|
||||
private JpaSoftwareModuleType smType;
|
||||
|
||||
@Setter
|
||||
|
||||
@@ -87,7 +87,7 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(
|
||||
name = "distribution_set", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_distribution_set"))
|
||||
@NotNull
|
||||
private JpaDistributionSet distributionSet;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(
|
||||
name = "target", updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_act_hist_targ"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target"))
|
||||
@NotNull
|
||||
private JpaTarget target;
|
||||
|
||||
@@ -135,8 +135,8 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(
|
||||
name = "rolloutgroup", updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup"))
|
||||
name = "rollout_group", updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout_group"))
|
||||
private JpaRolloutGroup rolloutGroup;
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(
|
||||
name = "action", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_status_action"))
|
||||
@NotNull
|
||||
private JpaAction action;
|
||||
|
||||
@@ -82,9 +82,9 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
||||
@CollectionTable(
|
||||
name = "sp_action_status_messages",
|
||||
joinColumns = @JoinColumn(
|
||||
name = "action_status_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_stat_msg_act_stat")),
|
||||
indexes = { @Index(name = "sp_idx_action_status_msgs_01", columnList = "action_status_id") })
|
||||
name = "action_status", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_status_messages_action_status")),
|
||||
indexes = { @Index(name = "fk_action_status_messages_action_status", columnList = "action_status") })
|
||||
@Column(name = "detail_message", length = MESSAGE_ENTRY_LENGTH, nullable = false)
|
||||
private List<String> messages;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Art
|
||||
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST }, fetch = FetchType.LAZY)
|
||||
@JoinColumn(
|
||||
name = "software_module", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_assigned_sm"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_artifact_software_module"))
|
||||
private JpaSoftwareModule softwareModule;
|
||||
|
||||
@Column(name = "provided_file_name", length = 256, updatable = false)
|
||||
|
||||
@@ -37,7 +37,9 @@ public class JpaAutoConfirmationStatus extends AbstractJpaTenantAwareBaseEntity
|
||||
|
||||
// actually it is OneToOne - but lazy loading is not supported for OneToOne (at least for hibernate 6.6.2)
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "target_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_auto_conf"))
|
||||
@JoinColumn(
|
||||
name = "target", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_conf_status_target"))
|
||||
private JpaTarget target;
|
||||
|
||||
@Column(name = "initiator", length = USERNAME_FIELD_LENGTH)
|
||||
|
||||
@@ -62,7 +62,7 @@ import org.springframework.context.ApplicationEvent;
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "sp_distribution_set",
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distrib_set") },
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distribution_set") },
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_01", columnList = "tenant,deleted,complete"),
|
||||
@Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") })
|
||||
@@ -75,40 +75,38 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String DELETED_PROPERTY = "deleted";
|
||||
|
||||
@Setter
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = JpaDistributionSetType.class)
|
||||
@JoinColumn(
|
||||
name = "ds_id", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
|
||||
name = "ds_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_distribution_set_ds_type"))
|
||||
@NotNull
|
||||
private DistributionSetType type;
|
||||
|
||||
@ManyToMany(targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "sp_ds_module",
|
||||
name = "sp_ds_sm",
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "ds_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_sm_ds_id")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "module_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||
name = "sm_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_sm_sm_id")) })
|
||||
private Set<SoftwareModule> modules = new HashSet<>();
|
||||
|
||||
@ManyToMany(targetEntity = JpaDistributionSetTag.class)
|
||||
@JoinTable(
|
||||
name = "sp_ds_dstag",
|
||||
name = "sp_ds_tag",
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "ds", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_tag_ds")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "TAG", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
||||
name = "tag", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_tag_tag")) })
|
||||
private Set<DistributionSetTag> tags = new HashSet<>();
|
||||
|
||||
@ToString.Exclude
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JpaDistributionSetMetadata extends AbstractJpaMetaData implements D
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "ds_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds"))
|
||||
@JoinColumn(name = "ds", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_metadata_ds"))
|
||||
private JpaDistributionSet distributionSet;
|
||||
|
||||
public JpaDistributionSetMetadata(final String key, final String value) {
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
*/
|
||||
@NoArgsConstructor // Default constructor needed for JPA entities.
|
||||
@Entity
|
||||
@Table(name = "sp_distributionset_tag",
|
||||
@Table(name = "sp_distribution_set_tag",
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_distribution_set_tag_01", columnList = "tenant,name") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_ds_tag"))
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_distribution_set_tag"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity {
|
||||
|
||||
@@ -49,8 +49,8 @@ import org.springframework.util.CollectionUtils;
|
||||
@Table(name = "sp_distribution_set_type", indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_type_01", columnList = "tenant,deleted"),
|
||||
@Index(name = "sp_idx_distribution_set_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_dst_name"),
|
||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_dst_key") })
|
||||
@UniqueConstraint(columnNames = { "tenant", "type_key"}, name = "uk_sp_distribution_set_type_type_key"),
|
||||
@UniqueConstraint(columnNames = { "tenant", "name" }, name = "uk_sp_distribution_set_type_name") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSetType extends AbstractJpaTypeEntity implements DistributionSetType, EventAwareEntity {
|
||||
|
||||
@@ -81,7 +81,9 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
|
||||
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "distribution_set", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds"))
|
||||
@JoinColumn(
|
||||
name = "distribution_set", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_distribution_set"))
|
||||
@NotNull
|
||||
private JpaDistributionSet distributionSet;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
*/
|
||||
@NoArgsConstructor // Default constructor needed for JPA entities.
|
||||
@Entity
|
||||
@Table(name = "sp_rolloutgroup", uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout", "tenant" }, name = "uk_rolloutgroup"))
|
||||
@Table(name = "sp_rollout_group", uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout", "tenant" }, name = "uk_rollout_group"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGroup, EventAwareEntity {
|
||||
@@ -56,7 +56,9 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
||||
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "rollout", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout"))
|
||||
@JoinColumn(
|
||||
name = "rollout", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_group_rollout"))
|
||||
private JpaRollout rollout;
|
||||
|
||||
@Setter
|
||||
@@ -65,15 +67,16 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
||||
@Convert(converter = RolloutGroupStatusConverter.class)
|
||||
private RolloutGroupStatus status = RolloutGroupStatus.CREATING;
|
||||
|
||||
@OneToMany(mappedBy = "rolloutGroup", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST,
|
||||
CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class)
|
||||
@OneToMany(
|
||||
mappedBy = "rolloutGroup", fetch = FetchType.LAZY,
|
||||
cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class)
|
||||
private List<RolloutTargetGroup> rolloutTargetGroup;
|
||||
|
||||
// No foreign key to avoid to many nested cascades on delete which some DBs cannot handle
|
||||
@Setter
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumn(name = "parent_id")
|
||||
@JoinColumn(name = "parent")
|
||||
private JpaRolloutGroup parent;
|
||||
|
||||
@Setter
|
||||
|
||||
@@ -55,12 +55,12 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Getter
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "sp_base_software_module",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "module_type", "name", "version", "tenant" }, name = "uk_base_sw_mod"),
|
||||
@Table(name = "sp_software_module",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "sm_type", "name", "version", "tenant" }, name = "uk_software_module"),
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_base_sw_module_01", columnList = "tenant,deleted,name,version"),
|
||||
@Index(name = "sp_idx_base_sw_module_02", columnList = "tenant,deleted,module_type"),
|
||||
@Index(name = "sp_idx_base_sw_module_prim", columnList = "tenant,id") })
|
||||
@Index(name = "sp_idx_software_module_01", columnList = "tenant,deleted,name,version"),
|
||||
@Index(name = "sp_idx_software_module_02", columnList = "tenant,deleted,sm_type"),
|
||||
@Index(name = "sp_idx_software_module_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "SoftwareModule.artifacts", attributeNodes = { @NamedAttributeNode("artifacts") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
@@ -73,8 +73,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
||||
|
||||
@Setter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "module_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_module_type"))
|
||||
@JoinColumn(name = "sm_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_software_module_sm_type"))
|
||||
@NotNull
|
||||
private JpaSoftwareModuleType type;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
@ToString(callSuper = true)
|
||||
@IdClass(SwMetadataCompositeKey.class)
|
||||
@Entity
|
||||
@Table(name = "sp_sw_metadata")
|
||||
@Table(name = "sp_sm_metadata")
|
||||
public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements SoftwareModuleMetadata {
|
||||
|
||||
@Serial
|
||||
@@ -46,7 +46,7 @@ public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements So
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "sw_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
||||
@JoinColumn(name = "sm", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_sm_metadata_sm"))
|
||||
private JpaSoftwareModule softwareModule;
|
||||
|
||||
@Column(name = "target_visible")
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Table(name = "sp_software_module_type", indexes = {
|
||||
@Index(name = "sp_idx_software_module_type_01", columnList = "tenant,deleted"),
|
||||
@Index(name = "sp_idx_software_module_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_smt_type_key"),
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_smt_name") })
|
||||
@UniqueConstraint(columnNames = { "tenant", "type_key" }, name = "uk_sp_software_module_type_type_key"),
|
||||
@UniqueConstraint(columnNames = { "tenant", "name" }, name = "uk_sp_software_module_type_name") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaSoftwareModuleType extends AbstractJpaTypeEntity implements SoftwareModuleType, EventAwareEntity {
|
||||
|
||||
@@ -82,7 +82,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@Index(name = "sp_idx_target_04", columnList = "tenant,created_at"),
|
||||
@Index(name = "sp_idx_target_05", columnList = "tenant,last_modified_at"),
|
||||
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "controller_id", "tenant" }, name = "uk_tenant_controller_id"))
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "controller_id", "tenant" }, name = "uk_target_controller_id"))
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(name = "Target.details", attributeNodes = {
|
||||
@NamedAttributeNode("targetType"),
|
||||
@@ -173,11 +173,11 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "target", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_target_tag_target")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "tag", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_target_tag_tag"))
|
||||
})
|
||||
private Set<TargetTag> tags;
|
||||
|
||||
@@ -186,8 +186,8 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
@ElementCollection
|
||||
@CollectionTable(
|
||||
name = "sp_target_attributes",
|
||||
joinColumns = { @JoinColumn(name = "target_id", nullable = false) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
||||
joinColumns = { @JoinColumn(name = "target", nullable = false) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_attributes_target"))
|
||||
@Column(name = "attribute_value", length = Target.CONTROLLER_ATTRIBUTE_VALUE_SIZE)
|
||||
@MapKeyColumn(name = "attribute_key", length = Target.CONTROLLER_ATTRIBUTE_KEY_SIZE)
|
||||
private Map<String, String> controllerAttributes;
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Entity
|
||||
@Table(
|
||||
name = "sp_target_filter_query",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_tenant_custom_filter_name"))
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_filter_query"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery, EventAwareEntity {
|
||||
@@ -65,23 +65,25 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity imple
|
||||
private String query;
|
||||
|
||||
@ManyToOne(optional = true, fetch = FetchType.LAZY, targetEntity = JpaDistributionSet.class)
|
||||
@JoinColumn(name = "auto_assign_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_filter_auto_assign_ds"))
|
||||
@JoinColumn(
|
||||
name = "auto_assign_distribution_set",
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_filter_query_auto_assign_distribution_set"))
|
||||
private JpaDistributionSet autoAssignDistributionSet;
|
||||
|
||||
@Column(name = "auto_assign_action_type", nullable = true)
|
||||
@Column(name = "auto_assign_action_type")
|
||||
@Convert(converter = JpaAction.ActionTypeConverter.class)
|
||||
private ActionType autoAssignActionType;
|
||||
|
||||
@Column(name = "auto_assign_weight", nullable = true)
|
||||
@Column(name = "auto_assign_weight")
|
||||
private Integer autoAssignWeight;
|
||||
|
||||
@Column(name = "auto_assign_initiated_by", nullable = true, length = USERNAME_FIELD_LENGTH)
|
||||
@Column(name = "auto_assign_initiated_by", length = USERNAME_FIELD_LENGTH)
|
||||
private String autoAssignInitiatedBy;
|
||||
|
||||
@Column(name = "confirmation_required")
|
||||
private boolean confirmationRequired;
|
||||
|
||||
@Column(name = "access_control_context", nullable = true)
|
||||
@Column(name = "access_control_context")
|
||||
private String accessControlContext;
|
||||
|
||||
public JpaTargetFilterQuery(final String name, final String query, final DistributionSet autoAssignDistributionSet,
|
||||
|
||||
@@ -43,7 +43,9 @@ public class JpaTargetMetadata extends AbstractJpaMetaData implements TargetMeta
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "target_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_target"))
|
||||
@JoinColumn(
|
||||
name = "target", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_metadata_target"))
|
||||
private JpaTarget target;
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,9 +30,12 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "sp_target_tag", indexes = { @Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_target_tag_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_targ_tag"))
|
||||
@Table(
|
||||
name = "sp_target_tag",
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_target_tag_01", columnList = "tenant,name") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_tag"))
|
||||
public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Entity
|
||||
@Table(name = "sp_target_type", indexes = {
|
||||
@Index(name = "sp_idx_target_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_type_name") })
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_name") })
|
||||
@SuppressWarnings("java:S2160") // the super class equals/hashcode shall be used
|
||||
public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType, EventAwareEntity {
|
||||
|
||||
@@ -51,15 +51,15 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType,
|
||||
|
||||
@ManyToMany(targetEntity = JpaDistributionSetType.class)
|
||||
@JoinTable(
|
||||
name = "sp_target_type_ds_type_relation",
|
||||
name = "sp_target_type_ds_type",
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "target_type", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_target_type")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_ds_type_target_type")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "distribution_set_type", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_ds_type")) })
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_ds_type_distribution_set_type")) })
|
||||
private Set<DistributionSetType> distributionSetTypes = new HashSet<>();
|
||||
|
||||
public JpaTargetType(final String key, final String name, final String description, final String colour) {
|
||||
|
||||
@@ -35,8 +35,9 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Setter
|
||||
@Getter
|
||||
@Entity
|
||||
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
||||
"tenant" }, name = "uk_tenant_key"))
|
||||
@Table(
|
||||
name = "sp_tenant_configuration",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key", "tenant" }, name = "uk_tenant_configuration"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity implements TenantConfiguration, EventAwareEntity {
|
||||
|
||||
@@ -44,9 +44,10 @@ import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
@Setter
|
||||
@Getter
|
||||
@Table(name = "sp_tenant", indexes = {
|
||||
@Index(name = "sp_idx_tenant_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "tenant" }, name = "uk_tenantmd_tenant") })
|
||||
@Table(
|
||||
name = "sp_tenant",
|
||||
indexes = { @Index(name = "sp_idx_tenant_prim", columnList = "tenant,id") },
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = { "tenant" }, name = "uk_tenant") })
|
||||
@NamedEntityGraph(name = "TenantMetaData.withDetails", attributeNodes = { @NamedAttributeNode("defaultDsType") })
|
||||
@Entity
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@@ -62,7 +63,9 @@ public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMe
|
||||
private String tenant;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "default_ds_type", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_tenant_md_default_ds_type"))
|
||||
@JoinColumn(
|
||||
name = "default_ds_type", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_sp_tenant_default_ds_type"))
|
||||
private JpaDistributionSetType defaultDsType;
|
||||
|
||||
public JpaTenantMetaData(final DistributionSetType defaultDsType, final String tenant) {
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
@IdClass(RolloutTargetGroupId.class)
|
||||
@Entity
|
||||
@Table(name = "sp_rollouttargetgroup")
|
||||
@Table(name = "sp_rollout_target_group")
|
||||
public class RolloutTargetGroup implements Serializable {
|
||||
|
||||
@Serial
|
||||
@@ -44,20 +44,20 @@ public class RolloutTargetGroup implements Serializable {
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, targetEntity = JpaRolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumn(name = "rolloutGroup_Id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_group"))
|
||||
@JoinColumn(name = "rollout_group", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_target_group_rollout_group"))
|
||||
private JpaRolloutGroup rolloutGroup;
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, targetEntity = JpaTarget.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumn(
|
||||
name = "target_id", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_target"))
|
||||
name = "target", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_target_group_target"))
|
||||
private JpaTarget target;
|
||||
|
||||
@OneToMany(targetEntity = JpaAction.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumns(value = {
|
||||
@JoinColumn(name = "rolloutgroup", nullable = false, insertable = false, updatable = false, referencedColumnName = "rolloutGroup_Id"),
|
||||
@JoinColumn(name = "target", nullable = false, insertable = false, updatable = false, referencedColumnName = "target_id") })
|
||||
@JoinColumn(name = "rollout_group", nullable = false, insertable = false, updatable = false, referencedColumnName = "rollout_group"),
|
||||
@JoinColumn(name = "target", nullable = false, insertable = false, updatable = false, referencedColumnName = "target") })
|
||||
private List<JpaAction> actions;
|
||||
|
||||
public RolloutTargetGroup(final RolloutGroup rolloutGroup, final Target target) {
|
||||
|
||||
@@ -54,8 +54,8 @@ public interface RolloutGroupRepository extends BaseEntityRepository<JpaRolloutG
|
||||
* @param status the status of the rolloutgroups
|
||||
* @return The child {@link RolloutGroup}s in a specific status
|
||||
*/
|
||||
@Query("SELECT g FROM JpaRolloutGroup g WHERE g.parent.id=:rolloutGroupId and g.status=:status")
|
||||
List<JpaRolloutGroup> findByParentIdAndStatus(@Param("rolloutGroupId") long rolloutGroupId, @Param("status") RolloutGroupStatus status);
|
||||
@Query("SELECT g FROM JpaRolloutGroup g WHERE g.parent.id=:rollout_group and g.status=:status")
|
||||
List<JpaRolloutGroup> findByParentIdAndStatus(@Param("rollout_group") long rolloutGroupId, @Param("status") RolloutGroupStatus status);
|
||||
|
||||
/**
|
||||
* Updates all {@link RolloutGroup#getStatus()} of children for given parent.
|
||||
|
||||
Reference in New Issue
Block a user