From 716f24202537d59b3752678dddf854d58dc79158 Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 13 Jun 2024 09:06:27 +0200 Subject: [PATCH 01/14] create delete user script for dhis2 --- DHIS2/delete_users/.gitignore | 9 +++ DHIS2/delete_users/README.md | 25 +++++++ DHIS2/delete_users/clean_temp.sh | 3 + DHIS2/delete_users/create_sql_query.py | 39 +++++++++++ DHIS2/delete_users/remove_users.py | 93 ++++++++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 DHIS2/delete_users/.gitignore create mode 100644 DHIS2/delete_users/README.md create mode 100644 DHIS2/delete_users/clean_temp.sh create mode 100644 DHIS2/delete_users/create_sql_query.py create mode 100644 DHIS2/delete_users/remove_users.py diff --git a/DHIS2/delete_users/.gitignore b/DHIS2/delete_users/.gitignore new file mode 100644 index 00000000..04b1e8d0 --- /dev/null +++ b/DHIS2/delete_users/.gitignore @@ -0,0 +1,9 @@ +# Local files +working_notes +docker_log.log +error* +output* +temp* + +# User exports +user* \ No newline at end of file diff --git a/DHIS2/delete_users/README.md b/DHIS2/delete_users/README.md new file mode 100644 index 00000000..eab7e725 --- /dev/null +++ b/DHIS2/delete_users/README.md @@ -0,0 +1,25 @@ +Remove users from DHIS2 app + +Scripts should be started on the server where dhis2 logs and dhis2 database are available. + +Steps: + +1. Download user list from "User extended app" using json format +2. Following arguments are required for the script to run: +``` + json_file_path = '' # Path to JSON file downloaded in step 1 + api_endpoint = '' # API endpoint to send DELETE call + username = '' # API username + password = '' # API user password + log_file_path = '' # Path to dhis2 log file + user_to_takeover = '' # User to use as new owner of the object + image = '' # dhis2 image name +``` +3. Run the script: +``` +python -u remove_users.py +``` +4. Run bash script clean_temp.sh to remove all temp files created +``` +chmod +x clean_temp.sh && bash clean_temp.sh +``` \ No newline at end of file diff --git a/DHIS2/delete_users/clean_temp.sh b/DHIS2/delete_users/clean_temp.sh new file mode 100644 index 00000000..9873b2e7 --- /dev/null +++ b/DHIS2/delete_users/clean_temp.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rm -rf error_objects.json temp_log.txt output.sql \ No newline at end of file diff --git a/DHIS2/delete_users/create_sql_query.py b/DHIS2/delete_users/create_sql_query.py new file mode 100644 index 00000000..87f98eb4 --- /dev/null +++ b/DHIS2/delete_users/create_sql_query.py @@ -0,0 +1,39 @@ +import re +import sys + +def extract_and_write_queries(temp_log_file, sql_output_file, user_to_takeover): + with open(temp_log_file, 'r') as infile, open(sql_output_file, 'a') as outfile: + lines = infile.readlines() + for i in range(1, len(lines)): + line = lines[i] + if "Status code: 500" in line: + match = re.search(r"ID (\S+)\. Status code: 500", line) + if match: + some_id = match.group(1) + query1 = f"select userinfoid from userinfo where uid='{some_id}'\n" + + # Read the previous line + previous_line = lines[i - 1] + constraint_match = re.search(r'ERROR: update or delete on table "userinfo" violates foreign key constraint "(\S+)" on table "(\S+)"', previous_line) + if constraint_match: + query_user = f"select userinfoid from userinfo where username='{user_to_takeover}'\n" + some_constraint = constraint_match.group(1) + some_table = constraint_match.group(2) + if "lastupdateby" in some_constraint.lower(): + query2 = f"update {some_table} set lastupdatedby=({query_user.strip()}) where lastupdatedby=({query1.strip()});\n" + elif "creator" in some_constraint.lower(): + query2 = f"update {some_table} set creator=({query_user.strip()}) where creator=({query1.strip()});\n" + elif "assigneduserid" in some_constraint.lower(): + query2 = f"update {some_table} set assigneduserid=({query_user.strip()}) where assigneduserid=({query1.strip()});\n" + else: + query2 = f"update {some_table} set userid=({query_user.strip()}) where userid=({query1.strip()});\n" + + outfile.write(query2) + +if __name__ == "__main__": + + temp_log_file = sys.argv[1] + sql_output_file = sys.argv[2] + user_to_takeover = sys.argv[3] + + extract_and_write_queries(temp_log_file, sql_output_file, user_to_takeover) diff --git a/DHIS2/delete_users/remove_users.py b/DHIS2/delete_users/remove_users.py new file mode 100644 index 00000000..8d7b5441 --- /dev/null +++ b/DHIS2/delete_users/remove_users.py @@ -0,0 +1,93 @@ +import json +import requests +import subprocess +import threading +import sys + +stop_event = threading.Event() + +def delete_objects(json_file, api_endpoint, username, password, error_json_file_path, temp_log_file): + with open(json_file, 'r') as file: + data = json.load(file) + + error_objects = [] + + # Extract IDs and send DELETE requests + for item in data: + object_id = item.get('id') + if object_id: + url = f"{api_endpoint}/{object_id}" + response = requests.delete(url, auth=(username, password)) + if response.status_code in [200, 404, 409]: + print(f"Object with ID {object_id} deleted successfully") + else: + message = f"ERROR: Failed to delete object with ID {object_id}. Status code: {response.status_code}" + print(message) + with open(temp_log_file, 'a') as log: + log.write(message + "\n") + error_objects.append(item) + + # Write error objects to a different JSON file if there are users not deleted + if error_objects: + with open(error_json_file_path, 'w') as file: + json.dump(error_objects, file, indent=4) + + return bool(error_objects) + +def log_error_if_present(log_file_path, temp_log_file): + # Tail dhis2 log + cmd = ["tail", "-F", log_file_path] + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + while True: + output = process.stdout.readline() + if "ERROR: update or delete on table" in output: + message = f"{output.strip()}" + print(message) + with open(temp_log_file, 'a') as log: + log.write(message + "\n") + +def execute_create_sql_query_script(temp_log_file, sql_output_file, user_to_takeover): + subprocess.run(["python3", "create_sql_query.py", temp_log_file, sql_output_file, user_to_takeover]) + +def execute_sql_script(sql_output_file, image): + subprocess.run(["d2-docker", "run-sql", "-i", image, sql_output_file]) + +def main(): + json_file_path = sys.argv[1] # Path to JSON file with users to be deleted. Example: users.json + api_endpoint = sys.argv[2] # API endpoint DELETE users. Example: http://localhost:8080/api/38/users + username = sys.argv[3] # API username + password = sys.argv[4] # API password + log_file_path = sys.argv[5] # Path to dhis2 log file + error_json_file_path = 'error_objects.json' # Path to created JSON file containing not deleted users + user_to_takeover = sys.argv[6] # User to use as new owner of the object + image = sys.argv[7] # dhis2 image name + temp_log_file = 'temp_log.txt' # Input file to generate sql + sql_output_file = 'output.sql' # Output sql file + + while True: + # Create and start log thread + log_thread = threading.Thread(target=log_error_if_present, args=(log_file_path, temp_log_file)) + log_thread.start() + + # Run delete_objects function + has_errors = delete_objects(json_file_path, api_endpoint, username, password, error_json_file_path, temp_log_file) + + if not has_errors: + print("INFO: All objects deleted successfully. Exiting.") + # Stop the log thread + stop_event.set() + log_thread.join() + break + + # Extract user IDs from failed deletes and create sql query to fix dependencies + has_errors = execute_create_sql_query_script(temp_log_file, sql_output_file, user_to_takeover) + + # Execute sql script to fix dependencies + has_errors = execute_sql_script(sql_output_file, image) + + # Use the error file as the input for the next iteration + json_file_path = error_json_file_path + +if __name__ == "__main__": + main() From 788ca1f40ef57592ffa7a90f5d3a0165da0402fc Mon Sep 17 00:00:00 2001 From: milorad Date: Tue, 25 Jun 2024 09:54:32 +0200 Subject: [PATCH 02/14] create remove_users python script --- DHIS2/delete_users/.gitignore | 1 + DHIS2/delete_users/README.md | 6 +++--- DHIS2/delete_users/create_sql_query.py | 2 ++ DHIS2/delete_users/remove_users.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DHIS2/delete_users/.gitignore b/DHIS2/delete_users/.gitignore index 04b1e8d0..9af47b23 100644 --- a/DHIS2/delete_users/.gitignore +++ b/DHIS2/delete_users/.gitignore @@ -4,6 +4,7 @@ docker_log.log error* output* temp* +preprod* # User exports user* \ No newline at end of file diff --git a/DHIS2/delete_users/README.md b/DHIS2/delete_users/README.md index eab7e725..3371869d 100644 --- a/DHIS2/delete_users/README.md +++ b/DHIS2/delete_users/README.md @@ -4,11 +4,11 @@ Scripts should be started on the server where dhis2 logs and dhis2 database are Steps: -1. Download user list from "User extended app" using json format +1. Download user list from "User extended app" using json format or convert existing csv to json 2. Following arguments are required for the script to run: ``` - json_file_path = '' # Path to JSON file downloaded in step 1 - api_endpoint = '' # API endpoint to send DELETE call + json_file_path = '' # Path to JSON file downloaded/converted in step 1 + api_endpoint = '' # API endpoint to send DELETE call username = '' # API username password = '' # API user password log_file_path = '' # Path to dhis2 log file diff --git a/DHIS2/delete_users/create_sql_query.py b/DHIS2/delete_users/create_sql_query.py index 87f98eb4..a2dd4ae8 100644 --- a/DHIS2/delete_users/create_sql_query.py +++ b/DHIS2/delete_users/create_sql_query.py @@ -21,6 +21,8 @@ def extract_and_write_queries(temp_log_file, sql_output_file, user_to_takeover): some_table = constraint_match.group(2) if "lastupdateby" in some_constraint.lower(): query2 = f"update {some_table} set lastupdatedby=({query_user.strip()}) where lastupdatedby=({query1.strip()});\n" + elif "lastupdatedby" in some_constraint.lower(): + query2 = f"update {some_table} set lastupdatedby=({query_user.strip()}) where lastupdatedby=({query1.strip()});\n" elif "creator" in some_constraint.lower(): query2 = f"update {some_table} set creator=({query_user.strip()}) where creator=({query1.strip()});\n" elif "assigneduserid" in some_constraint.lower(): diff --git a/DHIS2/delete_users/remove_users.py b/DHIS2/delete_users/remove_users.py index 8d7b5441..1a04b9d1 100644 --- a/DHIS2/delete_users/remove_users.py +++ b/DHIS2/delete_users/remove_users.py @@ -14,7 +14,7 @@ def delete_objects(json_file, api_endpoint, username, password, error_json_file_ # Extract IDs and send DELETE requests for item in data: - object_id = item.get('id') + object_id = item.get('ID') if object_id: url = f"{api_endpoint}/{object_id}" response = requests.delete(url, auth=(username, password)) From 6b6d9c30ac9eae6f0960ef87c30bc20878172d8c Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 4 Jul 2024 18:18:13 +0200 Subject: [PATCH 03/14] add sql init --- DHIS2/delete_users/README.md | 2 +- DHIS2/delete_users/init-preprod-indiv.sql | 5 +++++ DHIS2/delete_users/init-preprod.sql | 6 ++++++ DHIS2/delete_users/remove_users.py | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 DHIS2/delete_users/init-preprod-indiv.sql create mode 100644 DHIS2/delete_users/init-preprod.sql diff --git a/DHIS2/delete_users/README.md b/DHIS2/delete_users/README.md index 3371869d..a7989145 100644 --- a/DHIS2/delete_users/README.md +++ b/DHIS2/delete_users/README.md @@ -8,7 +8,7 @@ Steps: 2. Following arguments are required for the script to run: ``` json_file_path = '' # Path to JSON file downloaded/converted in step 1 - api_endpoint = '' # API endpoint to send DELETE call + api_endpoint = '' # API endpoint to send DELETE call. username = '' # API username password = '' # API user password log_file_path = '' # Path to dhis2 log file diff --git a/DHIS2/delete_users/init-preprod-indiv.sql b/DHIS2/delete_users/init-preprod-indiv.sql new file mode 100644 index 00000000..642d4e53 --- /dev/null +++ b/DHIS2/delete_users/init-preprod-indiv.sql @@ -0,0 +1,5 @@ +create temp table tmp_list_userids (uid varchar); +copy tmp_list_userids from '/var/lib/postgresql/preprod-indiv-only-id.csv' CSV; + +select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql new file mode 100644 index 00000000..2dde8f52 --- /dev/null +++ b/DHIS2/delete_users/init-preprod.sql @@ -0,0 +1,6 @@ +create temp table tmp_list_userids (uid varchar); +copy tmp_list_userids from '/var/lib/postgresql/preprod-only-id.csv' CSV; + +select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='10722029'; diff --git a/DHIS2/delete_users/remove_users.py b/DHIS2/delete_users/remove_users.py index 1a04b9d1..d4f46ae8 100644 --- a/DHIS2/delete_users/remove_users.py +++ b/DHIS2/delete_users/remove_users.py @@ -3,6 +3,7 @@ import subprocess import threading import sys +import time stop_event = threading.Event() @@ -26,6 +27,7 @@ def delete_objects(json_file, api_endpoint, username, password, error_json_file_ with open(temp_log_file, 'a') as log: log.write(message + "\n") error_objects.append(item) + time.sleep(1) # Sleep for 1 second between API calls # Write error objects to a different JSON file if there are users not deleted if error_objects: @@ -50,6 +52,9 @@ def log_error_if_present(log_file_path, temp_log_file): def execute_create_sql_query_script(temp_log_file, sql_output_file, user_to_takeover): subprocess.run(["python3", "create_sql_query.py", temp_log_file, sql_output_file, user_to_takeover]) +def execute_init_sql_script(image, sql_init_file): + subprocess.run(["d2-docker", "run-sql", "-i", image, sql_init_file]) + def execute_sql_script(sql_output_file, image): subprocess.run(["d2-docker", "run-sql", "-i", image, sql_output_file]) @@ -64,12 +69,16 @@ def main(): image = sys.argv[7] # dhis2 image name temp_log_file = 'temp_log.txt' # Input file to generate sql sql_output_file = 'output.sql' # Output sql file + sql_init_file = [8] # init sql file per instance while True: # Create and start log thread log_thread = threading.Thread(target=log_error_if_present, args=(log_file_path, temp_log_file)) log_thread.start() + # Run init sql script + has_errors = execute_init_sql_script(image, sql_init_file) + # Run delete_objects function has_errors = delete_objects(json_file_path, api_endpoint, username, password, error_json_file_path, temp_log_file) From 274f63f2d42f61ec706a5f2126ec64ddc65c781c Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 11 Jul 2024 12:30:38 +0200 Subject: [PATCH 04/14] update sql init queryis for the script --- DHIS2/delete_users/.gitignore | 5 +++- DHIS2/delete_users/.sample-env | 8 ++++++ DHIS2/delete_users/README.md | 21 +++++---------- DHIS2/delete_users/init-preprod-indiv.sql | 5 ---- DHIS2/delete_users/init-preprod.sql | 12 ++++++++- DHIS2/delete_users/init.sql | 15 +++++++++++ DHIS2/delete_users/remove_users.py | 31 ++++++++++++++--------- 7 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 DHIS2/delete_users/.sample-env delete mode 100644 DHIS2/delete_users/init-preprod-indiv.sql create mode 100644 DHIS2/delete_users/init.sql diff --git a/DHIS2/delete_users/.gitignore b/DHIS2/delete_users/.gitignore index 9af47b23..a8046d80 100644 --- a/DHIS2/delete_users/.gitignore +++ b/DHIS2/delete_users/.gitignore @@ -7,4 +7,7 @@ temp* preprod* # User exports -user* \ No newline at end of file +user* + +# env files +.env diff --git a/DHIS2/delete_users/.sample-env b/DHIS2/delete_users/.sample-env new file mode 100644 index 00000000..ef9b6bfd --- /dev/null +++ b/DHIS2/delete_users/.sample-env @@ -0,0 +1,8 @@ +JSON_FILE_PATH="" # Path to JSON file with users to be deleted +API_ENDPOINT="" # API endpoint DELETE users (example: http://localhost:8080/api/38/users) +USERNAME="" # API username +PASSWD="" # API password +LOG_FILE_PATH="" # Path to dhis2 log file +USER_TO_TAKEOVER="" # User to use as new owner of the object +DHIS2_DATA_IMAGE="" # Dhis2 image name +SQL_INIT_FILE="" # Init sql file (init.sql, or init-preprod.sql only for preprod) \ No newline at end of file diff --git a/DHIS2/delete_users/README.md b/DHIS2/delete_users/README.md index a7989145..5957bcb4 100644 --- a/DHIS2/delete_users/README.md +++ b/DHIS2/delete_users/README.md @@ -1,25 +1,18 @@ -Remove users from DHIS2 app +Remove users from DHIS2 instnces Scripts should be started on the server where dhis2 logs and dhis2 database are available. Steps: 1. Download user list from "User extended app" using json format or convert existing csv to json -2. Following arguments are required for the script to run: +2. Create another csv file coping only ID column, use it only in step 3 +3. Copy newly created csv file to dhis2 DB container to this path: /var/lib/postgresql/data/init.csv +4. Create .env file from .sample-env +5. Run the script: ``` - json_file_path = '' # Path to JSON file downloaded/converted in step 1 - api_endpoint = '' # API endpoint to send DELETE call. - username = '' # API username - password = '' # API user password - log_file_path = '' # Path to dhis2 log file - user_to_takeover = '' # User to use as new owner of the object - image = '' # dhis2 image name +python remove_users.py ``` -3. Run the script: -``` -python -u remove_users.py -``` -4. Run bash script clean_temp.sh to remove all temp files created +6. Run bash script clean_temp.sh to remove all temp files created ``` chmod +x clean_temp.sh && bash clean_temp.sh ``` \ No newline at end of file diff --git a/DHIS2/delete_users/init-preprod-indiv.sql b/DHIS2/delete_users/init-preprod-indiv.sql deleted file mode 100644 index 642d4e53..00000000 --- a/DHIS2/delete_users/init-preprod-indiv.sql +++ /dev/null @@ -1,5 +0,0 @@ -create temp table tmp_list_userids (uid varchar); -copy tmp_list_userids from '/var/lib/postgresql/preprod-indiv-only-id.csv' CSV; - -select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 2dde8f52..9c9ca659 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -1,6 +1,16 @@ create temp table tmp_list_userids (uid varchar); -copy tmp_list_userids from '/var/lib/postgresql/preprod-only-id.csv' CSV; +copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='10722029'; + +select count(*) from fileresource where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +select count(*) from fileresource where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + +select count(*) from document where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +select count(*) from document where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); \ No newline at end of file diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql new file mode 100644 index 00000000..e60e3f67 --- /dev/null +++ b/DHIS2/delete_users/init.sql @@ -0,0 +1,15 @@ +create temp table tmp_list_userids (uid varchar); +copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; + +select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + +select count(*) from fileresource where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +select count(*) from fileresource where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + +select count(*) from document where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +select count(*) from document where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/remove_users.py b/DHIS2/delete_users/remove_users.py index d4f46ae8..8b0b1111 100644 --- a/DHIS2/delete_users/remove_users.py +++ b/DHIS2/delete_users/remove_users.py @@ -2,9 +2,12 @@ import requests import subprocess import threading -import sys -import time +#import sys +import os +from dotenv import load_dotenv +#import time +load_dotenv() stop_event = threading.Event() def delete_objects(json_file, api_endpoint, username, password, error_json_file_path, temp_log_file): @@ -19,15 +22,19 @@ def delete_objects(json_file, api_endpoint, username, password, error_json_file_ if object_id: url = f"{api_endpoint}/{object_id}" response = requests.delete(url, auth=(username, password)) - if response.status_code in [200, 404, 409]: + if response.status_code == 200: print(f"Object with ID {object_id} deleted successfully") + elif response.status_code == 409: + print(f"Object with ID {object_id} has document attached and can not be deleted!") + elif response.status_code == 404: + print(f"Object with ID {object_id} not exists, skiping.") else: message = f"ERROR: Failed to delete object with ID {object_id}. Status code: {response.status_code}" print(message) with open(temp_log_file, 'a') as log: log.write(message + "\n") error_objects.append(item) - time.sleep(1) # Sleep for 1 second between API calls + #time.sleep(1) # Sleep for 1 second between API calls # Write error objects to a different JSON file if there are users not deleted if error_objects: @@ -59,17 +66,17 @@ def execute_sql_script(sql_output_file, image): subprocess.run(["d2-docker", "run-sql", "-i", image, sql_output_file]) def main(): - json_file_path = sys.argv[1] # Path to JSON file with users to be deleted. Example: users.json - api_endpoint = sys.argv[2] # API endpoint DELETE users. Example: http://localhost:8080/api/38/users - username = sys.argv[3] # API username - password = sys.argv[4] # API password - log_file_path = sys.argv[5] # Path to dhis2 log file + json_file_path = os.getenv('JSON_FILE_PATH') # Path to JSON file with users to be deleted. Example: users.json + api_endpoint = os.getenv('API_ENDPOINT') # API endpoint DELETE users. Example: http://localhost:8080/api/38/users + username = os.getenv('USERNAME') # API username + password = os.getenv('PASSWD') # API password + log_file_path = os.getenv('LOG_FILE_PATH') # Path to dhis2 log file error_json_file_path = 'error_objects.json' # Path to created JSON file containing not deleted users - user_to_takeover = sys.argv[6] # User to use as new owner of the object - image = sys.argv[7] # dhis2 image name + user_to_takeover = os.getenv('USER_TO_TAKEOVER') # User to use as new owner of the object + image = os.getenv('DHIS2_DATA_IMAGE') # Dhis2 image name temp_log_file = 'temp_log.txt' # Input file to generate sql sql_output_file = 'output.sql' # Output sql file - sql_init_file = [8] # init sql file per instance + sql_init_file = os.getenv('SQL_INIT_FILE') # Init sql file per instance while True: # Create and start log thread From a05cfdc08bb54ff2d4d41204a0bae02ce03d16e5 Mon Sep 17 00:00:00 2001 From: milorad Date: Fri, 12 Jul 2024 09:28:23 +0200 Subject: [PATCH 05/14] update sql init queries --- DHIS2/delete_users/init-preprod.sql | 36 ++++++++++++++++++++++++++++- DHIS2/delete_users/init.sql | 33 ++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 9c9ca659..4ddbf694 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -4,6 +4,7 @@ copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='10722029'; +update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='11175862'; select count(*) from fileresource where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from fileresource where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -13,4 +14,37 @@ update fileresource set lastupdatedby=(select userinfoid from userinfo where use select count(*) from document where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from document where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update document set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); \ No newline at end of file +update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + +update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitycomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityinstance set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update messageconversation set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index e60e3f67..42fd2de6 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -13,3 +13,36 @@ select count(*) from document where userid in (select userinfoid from userinfo w select count(*) from document where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update document set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + +update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitycomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityinstance set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update messageconversation set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From 780bb90f1d16e3c40d68b7486322682baeb70f4b Mon Sep 17 00:00:00 2001 From: milorad Date: Mon, 15 Jul 2024 11:29:26 +0200 Subject: [PATCH 06/14] update sql init script --- DHIS2/delete_users/init-preprod.sql | 11 +++++++++++ DHIS2/delete_users/init.sql | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 4ddbf694..7dc034d6 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -25,6 +25,7 @@ update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update keyjsonvalue set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update messageconversation set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -34,17 +35,27 @@ update programstageinstancefilter set lastupdatedby=(select userinfoid from user update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids));); +update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index 42fd2de6..9dd37c82 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -23,6 +23,7 @@ update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update keyjsonvalue set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update messageconversation set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -32,17 +33,27 @@ update programstageinstancefilter set lastupdatedby=(select userinfoid from user update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids));); +update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From 25ce28adc7131885dc16f32b3927e95eb160169f Mon Sep 17 00:00:00 2001 From: milorad Date: Mon, 15 Jul 2024 20:15:19 +0200 Subject: [PATCH 07/14] update init sql and python scripts --- DHIS2/delete_users/init-preprod.sql | 4 +--- DHIS2/delete_users/init.sql | 4 +--- DHIS2/delete_users/remove_users.py | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 7dc034d6..16469da9 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -17,9 +17,7 @@ update document set userid=(select userinfoid from userinfo where username='dev. update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitycomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityinstance set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentityattribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -57,5 +55,5 @@ update usergroup set lastupdatedby=(select userinfoid from userinfo where userna update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids));); +update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index 9dd37c82..473d2e63 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -15,9 +15,7 @@ update document set userid=(select userinfoid from userinfo where username='dev. update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitycomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityinstance set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentityattribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -55,5 +53,5 @@ update usergroup set lastupdatedby=(select userinfoid from userinfo where userna update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids));); +update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/remove_users.py b/DHIS2/delete_users/remove_users.py index 8b0b1111..201336ad 100644 --- a/DHIS2/delete_users/remove_users.py +++ b/DHIS2/delete_users/remove_users.py @@ -2,7 +2,7 @@ import requests import subprocess import threading -#import sys +import sys import os from dotenv import load_dotenv #import time @@ -26,6 +26,7 @@ def delete_objects(json_file, api_endpoint, username, password, error_json_file_ print(f"Object with ID {object_id} deleted successfully") elif response.status_code == 409: print(f"Object with ID {object_id} has document attached and can not be deleted!") + print() elif response.status_code == 404: print(f"Object with ID {object_id} not exists, skiping.") else: @@ -94,7 +95,7 @@ def main(): # Stop the log thread stop_event.set() log_thread.join() - break + sys.exit(0) # Extract user IDs from failed deletes and create sql query to fix dependencies has_errors = execute_create_sql_query_script(temp_log_file, sql_output_file, user_to_takeover) From 934d94dc5942392b2610de470c2c950402d6c58d Mon Sep 17 00:00:00 2001 From: milorad Date: Tue, 16 Jul 2024 13:22:36 +0200 Subject: [PATCH 08/14] update sql init script --- DHIS2/delete_users/init-preprod.sql | 3 +++ DHIS2/delete_users/init.sql | 1 + 2 files changed, 4 insertions(+) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 16469da9..844f5ddd 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -1,7 +1,10 @@ create temp table tmp_list_userids (uid varchar); copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; +select count(*) from userinfo where userinfoid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='10722029'; update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='11175862'; diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index 473d2e63..c513ae84 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -3,6 +3,7 @@ copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from fileresource where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from fileresource where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From 6514cb8eec9f3faaa323c46b7f5d45ed363d265f Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 18 Jul 2024 14:00:35 +0200 Subject: [PATCH 09/14] update sql init script --- DHIS2/delete_users/create_sql_query.py | 6 +++- DHIS2/delete_users/init-preprod.sql | 47 +++++++++++++++++++++++++- DHIS2/delete_users/init.sql | 44 ++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/DHIS2/delete_users/create_sql_query.py b/DHIS2/delete_users/create_sql_query.py index a2dd4ae8..4b3f313a 100644 --- a/DHIS2/delete_users/create_sql_query.py +++ b/DHIS2/delete_users/create_sql_query.py @@ -30,7 +30,11 @@ def extract_and_write_queries(temp_log_file, sql_output_file, user_to_takeover): else: query2 = f"update {some_table} set userid=({query_user.strip()}) where userid=({query1.strip()});\n" - outfile.write(query2) + lines_present = set() + for l in temp_log_file: + if l not in lines_present: + outfile.write(query2) + lines_present.add(l) if __name__ == "__main__": diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 844f5ddd..c228f1fb 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -4,7 +4,7 @@ copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV select count(*) from userinfo where userinfoid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userinfo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='10722029'; update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='11175862'; @@ -31,32 +31,77 @@ update messageconversation set userid=(select userinfoid from userinfo where use update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update categorycombo set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptioncombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstance set assigneduserid=(select userinfoid from userinfo where username='dev.user') where assigneduserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstageinstancefilter set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboarditem set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update indicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update optionset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagedataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrule set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programruleaction set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrulevariable set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovallevel set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataentryform set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update interpretationcomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update intepretation_likedby set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update report set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrule set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrulegroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); + diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index c513ae84..6e20ee7a 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -27,32 +27,76 @@ update messageconversation set userid=(select userinfoid from userinfo where use update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update categorycombo set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptioncombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstance set assigneduserid=(select userinfoid from userinfo where username='dev.user') where assigneduserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstageinstancefilter set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboarditem set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update indicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update optionset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagedataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrule set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programruleaction set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrulevariable set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovallevel set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataentryform set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update interpretationcomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update intepretation_likedby set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update report set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrule set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrulegroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From b953a2a5341f4672afb0b66f952163181887a5c9 Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 18 Jul 2024 17:37:25 +0200 Subject: [PATCH 10/14] update sql init script --- DHIS2/delete_users/init-preprod.sql | 5 ++++- DHIS2/delete_users/init.sql | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index c228f1fb..d17ba360 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -84,6 +84,8 @@ update dataentryform set lastupdatedby=(select userinfoid from userinfo where us update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update mapview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -104,4 +106,5 @@ update categoryoptiongroup set userid=(select userinfoid from userinfo where use update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update validationrule set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update validationrulegroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); - +update externalfileresource set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update pushanalysis set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index 6e20ee7a..e37b0755 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -80,6 +80,8 @@ update dataentryform set lastupdatedby=(select userinfoid from userinfo where us update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update mapview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -100,3 +102,5 @@ update categoryoptiongroup set userid=(select userinfoid from userinfo where use update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update validationrule set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update validationrulegroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update externalfileresource set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update pushanalysis set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From ca1a05360eac61c2d94d4a8c09ebc8f3e2026943 Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 18 Jul 2024 18:23:57 +0200 Subject: [PATCH 11/14] update init sql --- DHIS2/delete_users/init-preprod.sql | 1 - DHIS2/delete_users/init.sql | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index d17ba360..34e8733d 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -84,7 +84,6 @@ update dataentryform set lastupdatedby=(select userinfoid from userinfo where us update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update mapview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update map set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index e37b0755..8ab5a7e2 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -1,5 +1,7 @@ create temp table tmp_list_userids (uid varchar); copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; +#### second works in non docker, check if work in docker +\copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); @@ -80,7 +82,6 @@ update dataentryform set lastupdatedby=(select userinfoid from userinfo where us update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update mapview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update map set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From f7422b5a87bc673dcc20eb5e262ed31630f235e3 Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 18 Jul 2024 18:31:08 +0200 Subject: [PATCH 12/14] update init sql --- DHIS2/delete_users/init.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index 8ab5a7e2..38a0f592 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -1,6 +1,4 @@ create temp table tmp_list_userids (uid varchar); -copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; -#### second works in non docker, check if work in docker \copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From 7d245815f3cc73498b0b26655cf28ac5cc2d8b60 Mon Sep 17 00:00:00 2001 From: milorad Date: Thu, 18 Jul 2024 18:50:03 +0200 Subject: [PATCH 13/14] update init sql --- DHIS2/delete_users/init-preprod.sql | 186 ++++++++++++++-------------- DHIS2/delete_users/init.sql | 180 +++++++++++++-------------- 2 files changed, 183 insertions(+), 183 deletions(-) diff --git a/DHIS2/delete_users/init-preprod.sql b/DHIS2/delete_users/init-preprod.sql index 34e8733d..312f2cf2 100644 --- a/DHIS2/delete_users/init-preprod.sql +++ b/DHIS2/delete_users/init-preprod.sql @@ -4,106 +4,106 @@ copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV select count(*) from userinfo where userinfoid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userinfo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='10722029'; -update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid='11175862'; +update userinfo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='widp.deleted.reference') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='widp.deleted.reference') where creatoruserid='10722029'; +update userinfo set creatoruserid=(select userinfoid from userinfo where username='widp.deleted.reference') where creatoruserid='11175862'; select count(*) from fileresource where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from fileresource where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update fileresource set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update fileresource set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from document where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from document where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update document set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityattribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update keyjsonvalue set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update keyjsonvalue set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update messageconversation set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categorycombo set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categorycombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categoryoptioncombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstageinstance set assigneduserid=(select userinfoid from userinfo where username='dev.user') where assigneduserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstageinstancefilter set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dashboarditem set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicatorgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update eventvisualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update eventvisualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update optionset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update organisationunit set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstage set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstagedataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programrule set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programruleaction set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programrulevariable set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapproval set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapprovallevel set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update messageconversation set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptioncombo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstance set assigneduserid=(select userinfoid from userinfo where username='widp.deleted.reference') where assigneduserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboarditem set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategory set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroupset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroupset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update program set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagedataelement set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrule set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programruleaction set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrulevariable set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set creator=(select userinfoid from userinfo where username='widp.deleted.reference') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovallevel set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovalaudit set creator=(select userinfoid from userinfo where username='widp.deleted.reference') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataentryform set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update map set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update interpretationcomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update intepretation_likedby set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update constant set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update constant set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update optiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update report set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update sqlview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update sqlview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userrole set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userrole set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categoryoptiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update validationrule set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update validationrulegroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataentryform set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update mapview set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update interpretationcomment set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update intepretation_likedby set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optiongroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update report set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptiongroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrule set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrulegroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update externalfileresource set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update pushanalysis set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); diff --git a/DHIS2/delete_users/init.sql b/DHIS2/delete_users/init.sql index 38a0f592..cb6d2911 100644 --- a/DHIS2/delete_users/init.sql +++ b/DHIS2/delete_users/init.sql @@ -2,104 +2,104 @@ create temp table tmp_list_userids (uid varchar); \copy tmp_list_userids from '/var/lib/postgresql/data/init.csv' DELIMITER ',' CSV HEADER; select count(*) from userinfo where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userinfo set creatoruserid=(select userinfoid from userinfo where username='dev.user') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userinfo set creatoruserid=(select userinfoid from userinfo where username='widp.deleted.reference') where creatoruserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update userinfo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from fileresource where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from fileresource where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update fileresource set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update fileresource set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update fileresource set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from document where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); select count(*) from document where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update document set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update document set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update document set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityattribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitytype set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update keyjsonvalue set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update keyjsonvalue set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update messageconversation set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update visualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update visualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categorycombo set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categorycombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categoryoptioncombo set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstageinstance set assigneduserid=(select userinfoid from userinfo where username='dev.user') where assigneduserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstageinstancefilter set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dashboard set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dashboard set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dashboarditem set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelement set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementcategory set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataelementgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update indicatorgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update eventvisualization set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update eventvisualization set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update optionset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update optionset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update organisationunit set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update organisationunit set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroupset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update program set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicator set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicator set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstage set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstage set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programstagedataelement set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programrule set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programruleaction set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programrulevariable set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update usergroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update usergroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapproval set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapproval set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapprovallevel set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataapprovalaudit set creator=(select userinfoid from userinfo where username='dev.user') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitycomment set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityinstance set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentityattribute set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update trackedentitytype set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update keyjsonvalue set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update messageconversation set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update visualization set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categorycombo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptioncombo set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstance set assigneduserid=(select userinfoid from userinfo where username='widp.deleted.reference') where assigneduserid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstageinstancefilter set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboard set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dashboarditem set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelement set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategory set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementcategoryoption set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataelementgroupset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicator set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update indicatorgroupset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update eventvisualization set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optionset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update organisationunit set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update orgunitgroupset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update program set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicator set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstage set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagesection set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programstagedataelement set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrule set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programruleaction set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programrulevariable set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update usergroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set creator=(select userinfoid from userinfo where username='widp.deleted.reference') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapproval set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovallevel set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataapprovalaudit set creator=(select userinfoid from userinfo where username='widp.deleted.reference') where creator in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update dataapprovalworkflow set userid=(select userinfoid from userinfo where username='dev.suer') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update dataentryform set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update attribute set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update attribute set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update mapview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update map set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update map set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update maplegendset set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update interpretationcomment set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update intepretation_likedby set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update constant set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update constant set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update optiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicatorgroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programindicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update programnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update report set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update sqlview set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update sqlview set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userrole set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update userrole set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update categoryoptiongroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='dev.user') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update validationrule set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); -update validationrulegroup set userid=(select userinfoid from userinfo where username='dev.user') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update dataentryform set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update attribute set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update mapview set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update map set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update maplegendset set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update interpretationcomment set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update intepretation_likedby set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update constant set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update optiongroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programindicatorgroup set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update programnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update report set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update sqlview set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update userrole set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update categoryoptiongroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationnotificationtemplate set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrule set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); +update validationrulegroup set userid=(select userinfoid from userinfo where username='widp.deleted.reference') where userid in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update externalfileresource set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); update pushanalysis set lastupdatedby=(select userinfoid from userinfo where username='widp.deleted.reference') where lastupdatedby in (select userinfoid from userinfo where uid in (select uid from tmp_list_userids)); From 40272998e76f6ded696d0e1262da929d56fb552a Mon Sep 17 00:00:00 2001 From: milorad Date: Fri, 19 Jul 2024 10:06:47 +0200 Subject: [PATCH 14/14] add sleep command between api calls --- DHIS2/delete_users/remove_users.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DHIS2/delete_users/remove_users.py b/DHIS2/delete_users/remove_users.py index 201336ad..faa0319f 100644 --- a/DHIS2/delete_users/remove_users.py +++ b/DHIS2/delete_users/remove_users.py @@ -5,7 +5,7 @@ import sys import os from dotenv import load_dotenv -#import time +import time load_dotenv() stop_event = threading.Event() @@ -35,7 +35,7 @@ def delete_objects(json_file, api_endpoint, username, password, error_json_file_ with open(temp_log_file, 'a') as log: log.write(message + "\n") error_objects.append(item) - #time.sleep(1) # Sleep for 1 second between API calls + time.sleep(1) # Sleep for 1 second between API calls # Write error objects to a different JSON file if there are users not deleted if error_objects: