ALTER TABLE clients ADD personal_manager_id NUMBER(19) REFERENCES users(id);
CREATE INDEX clients_personal_manager_id_ix ON clients (personal_manager_id);

UPDATE clients SET personal_manager_id = (
    SELECT sub.user_id
    FROM (
         SELECT user_id, ROWNUM rnum
         FROM personal_managers
         WHERE client_id = clients.id
    ) sub
    WHERE sub.rnum = 1
);

DROP INDEX personal_managers_user_client_uniq;
DROP TABLE personal_managers;
