Skip to content
Snippets Groups Projects
Commit f2cf8ce1 authored by vkovtun's avatar vkovtun
Browse files

SSDM-14216: Not doing update for frozen entities to avoid errors.

parent ac753dca
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -46,9 +46,9 @@ public class ELNFixes {
storageValidationLevelFix(sessionToken, api);
nameNoRTFFix(sessionToken, api);
// TODO(alaskowski): SSDM-13831: Do migration here!!!
fixProperties("sample_properties", "sample_type_property_types", "stpt_id");
fixProperties("experiment_properties", "experiment_type_property_types", "etpt_id");
fixProperties("data_set_properties", "data_set_type_property_types", "dstpt_id");
fixProperties("sample_properties", "sample_type_property_types", "stpt_id", "samp_frozen");
fixProperties("experiment_properties", "experiment_type_property_types", "etpt_id", "expe_frozen");
fixProperties("data_set_properties", "data_set_type_property_types", "dstpt_id", "dase_frozen");
operationLog.info("ELNFixes beforeUpgrade FINISH");
}
......@@ -135,23 +135,24 @@ public class ELNFixes {
}
private static void fixProperties(final String propertiesTable, final String entityTypePropertyTypesTable,
final String entityTypePropertyTypesColumn) {
final String entityTypePropertyTypesColumn, final String frozenColumn) {
ELNCollectionTypeMigration.executeNativeUpdate(
String.format("UPDATE %s prop\n"
+ "SET value = null\n"
+ "FROM %s etpt\n"
+ "INNER JOIN property_types prty ON etpt.prty_id = prty.id\n"
+ "INNER JOIN data_types daty ON prty.daty_id = daty.id\n"
+ "WHERE prop.%s IS NOT NULL AND prop.%s = etpt.id AND daty.code = 'CONTROLLEDVOCABULARY'",
propertiesTable, entityTypePropertyTypesTable, entityTypePropertyTypesColumn, entityTypePropertyTypesColumn));
+ "WHERE prop.%s IS NOT NULL AND prop.%s = etpt.id AND daty.code = 'CONTROLLEDVOCABULARY' AND prop.%s = false",
propertiesTable, entityTypePropertyTypesTable, entityTypePropertyTypesColumn, entityTypePropertyTypesColumn, frozenColumn));
ELNCollectionTypeMigration.executeNativeUpdate(
String.format("UPDATE %s prop\n"
+ "SET cvte_id = null\n"
+ "FROM %s etpt\n"
+ "INNER JOIN property_types prty ON etpt.prty_id = prty.id\n"
+ "INNER JOIN data_types daty ON prty.daty_id = daty.id\n"
+ "WHERE prop.%s IS NOT NULL AND prop.%s = etpt.id AND daty.code != 'CONTROLLEDVOCABULARY'",
propertiesTable, entityTypePropertyTypesTable, entityTypePropertyTypesColumn, entityTypePropertyTypesColumn));
+ "WHERE prop.%s IS NOT NULL AND prop.%s = etpt.id AND daty.code != 'CONTROLLEDVOCABULARY' AND prop.%s = false",
propertiesTable, entityTypePropertyTypesTable, entityTypePropertyTypesColumn, entityTypePropertyTypesColumn, frozenColumn));
operationLog.info(String.format("ELNFixes fixProperties for propertiesTable %s", propertiesTable));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment