We need to delete a user id and migrate all objects originally connected to it (as its ownerId) to another employee user id.

Is it possible ?

Like 0

Like

3 comments

Just like an idea (in PostgreSQL) how we changed one text value to another text value in all objects. Maybe you can find the way how to use this for replacing one Id to another

 

DO
$$
DECLARE 
rw record;
BEGIN
FOR rw IN 
    SELECT 'UPDATE "'||C.table_name||'"  SET "'||C.column_name||'" = REPLACE ("'||C.COLUMN_NAME||'",''OldTextHere'',''NewTextHere''); ' QRY
    FROM (SELECT column_name,table_name 
          FROM   information_schema.columns 
          WHERE  table_schema='public' 
          AND    (data_type ='text' OR data_type ='character varying')
          AND    table_name in (SELECT table_name 
                                FROM   information_schema.tables 
                                WHERE  table_schema='public' 
                                AND    table_type ='BASE TABLE'))c
 
LOOP
    EXECUTE rw.QRY;
END LOOP;
END;
$$;

 

What if you just tried merging the two user contacts together? That would essentially reassign the owner value to the contact you retained. You might have some cleanup on the merged contact when done, but should work for all the reassignments

Ryan

Ryan Farley,

I could merge the two contacts.

Now I have two users connected to the same contact.

But cannot delete the user. There are still some objects connected to it... any clue ?

Show all comments