RED-8561: updated sql query to update existing dossier dictionaries with dossier_dictionary_only=true

This commit is contained in:
Ali Oezyetimoglu 2024-03-05 20:20:10 +01:00
parent 6bb3c93b84
commit a98cc0a6f2

View File

@ -1,7 +1,3 @@
-- SELECT * FROM entity WHERE id NOT LIKE ALL (SELECT e.id || '%' FROM entity e WHERE e.dossier_id IS NULL) AND dossier_id IS NOT NULL;
--
-- INSERT INTO entity
INSERT INTO entity (id, add_to_dictionary_action, description, dossier_id, dossier_template_id, hex_color, is_case_insensitive, is_hint, is_recommendation,
label, rank, type, version, recommendation_hex_color, has_dictionary, system_managed, auto_hide_skipped, soft_deleted_time, skipped_hex_color,
dossier_dictionary_only)
@ -9,4 +5,8 @@ SELECT (SELECT trim(trailing ':' from trim(trailing e.dossier_id from e.id))), e
e.label, e.rank, e.type, e.version, e.recommendation_hex_color, e.has_dictionary, e.system_managed, e.auto_hide_skipped, e.soft_deleted_time, e.skipped_hex_color,
TRUE
FROM entity e
WHERE (SELECT trim(trailing ':' from trim(trailing e.dossier_id from e.id))) IS NOT NULL AND (SELECT substr(e.id, POSITION(':' IN e.id) + POSITION(':' IN substr(e.id, POSITION(':' IN e.id) + 1)) + 1)) = '' IS FALSE;
WHERE (SELECT trim(trailing ':' from trim(trailing e.dossier_id from e.id))) IS NOT NULL AND (SELECT substr(e.id, POSITION(':' IN e.id) + POSITION(':' IN substr(e.id, POSITION(':' IN e.id) + 1)) + 1)) = '' IS FALSE;
UPDATE entity
SET dossier_dictionary_only = TRUE
WHERE starts_with(id, (SELECT trim(trailing ':' from trim(trailing dossier_id from id))));