Transfer personal collection to different user

Hello!

I’m using Metabase v0.55.2.1 with PostgreSQL and LDAP user authentication.

Recently a new user (e.g. with id=222) has been added. I need to "transfer" one of old (e.g. with id=111) user's personal collection (e.g. id=888) to this new user. The new user personal collection (e.g. id=999) automatically created but is obviously empty. The old user will not be used in future so it's collections other than the personal one are not important. The old and new users are in the same set of groups.
To summarize the example data (hope it make the question more clear):

user_id | collection_id | comment
111     | 888           | old user
222     | 999           | new user

I've tried swap users personal collections with the following:

update collection set personal_owner_id=NULL where id=999;
update collection set personal_owner_id=222 where id=888;
update collection set personal_owner_id=111 where id=999;

After this the new user (222) was not able to see "My personal collection" link in UI and saw "no permission" message trying to access the 888 collection. This made me think that personal collections permissions are affected by something else than personal_owner_id.

I tried to "revert" the change (again via NULLing due to DB constraints) but the new user reports inability to see "My personal collection" link in UI and permission issue for both old (222) and new (111) collections when using direct link.

So two questions:

  • Is there a way to return new (empty) collection to the new user?
  • What else to change to perform such a "transfer"

In the future, if you need to do this, Admin users can access all users’ personal collections and move items between them. Alternatively, you can create a new global collection, grant the involved users Curator permission on it, have the old user move the items into the collection, and have the new user pull the items back out. Or just leave them there; if you had to do this once, you’ll have to do it again later.

I can’t speak to how to fix your manual DB modifications. If nothing else was done to Metabase, it may be easier to restore the app DB from backup.

Thank you!

First of all, the "restoration" of personal_owner_id did work - today the new user was able to see the new personal collection again. Probably there is some kind of permissions cache which has been cleared by today because I did nothing else to return access. So probably the personal_owner_id swap would have worked too after some time but I decided to not try direct DB modifications again.

I also moved all the contents of old user's collection to new one's with standard "Move" from UI following dwhitemv advise. That was only about 250 questions so it was OK to do it by hand.

The old user also had some (24) "sub-collections" under personal collection. These were not visible to admin in any tree-like structure but luckily the user had a list of these "sub-collections" IDs (I don't know why this list was ever gathered). So to move these I've opened one of these "sub-collections" in browser by ID, moved it manually with browser inspector open, copied the request as cURL and moved the rest of "sub-collections" like:

set -e
for COL in 333 444 555; do
    echo "$COL"
    # headers with browser auth cookies have been removed from this code
    curl --fail "https://metabase.example.com/api/collection/${COL}" -X 'PUT' -H 'accept: application/json' -H 'content-type: application/json' --data-raw '{"parent_id":222,"archived":false}'
    echo "$?"
done

And this worked - the new user was able to see the "sub-collections" under new personal collection.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.