From c9a079201a38a4b5d272e8120c6daf7acb30bba5 Mon Sep 17 00:00:00 2001 From: Aaron Berndsen Date: Mon, 22 Apr 2024 09:53:55 -0300 Subject: [PATCH] docs: update "move all data" instructions in FAQ (#8976) * Update FAQ.mdx chore(docs): update "move all data" FAQ instructions. * Apply suggestions from code review fix: (apply suggestions) use sql-compliant comments Co-authored-by: Matthew Momjian <50788000+mmomjian@users.noreply.github.com> * fix: Update FAQ.mdx --------- Co-authored-by: Matthew Momjian <50788000+mmomjian@users.noreply.github.com> --- docs/docs/FAQ.mdx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/docs/FAQ.mdx b/docs/docs/FAQ.mdx index 033863bf51..508f543983 100644 --- a/docs/docs/FAQ.mdx +++ b/docs/docs/FAQ.mdx @@ -117,7 +117,7 @@ For example, say you have existing transcodes with the policy "Videos higher tha No. Our design principle is that the original assets should always be untouched. -### How can I move all data (photos, persons, albums) from one user to another? +### How can I move all data (photos, persons, albums, libraries) from one user to another? This is not officially supported but can be accomplished with some database updates. You can do this on the command line (in the PostgreSQL container using the `psql` command), or you can add, for example, an [Adminer](https://www.adminer.org/) container to the `docker-compose.yml` file so that you can use a web interface. @@ -128,18 +128,21 @@ This is not officially supported but can be accomplished with some database upda 2. Find the ID of both the 'source' and the 'destination' user (it's the id column in the `users` table) -3. Three tables need to be updated: +3. Four tables need to be updated: ```sql -// Reassign albums +-- reassign albums UPDATE albums SET "ownerId" = '' WHERE "ownerId" = ''; -// Reassign people +-- reassign people UPDATE person SET "ownerId" = '' WHERE "ownerId" = ''; -// reassign assets +-- reassign assets UPDATE assets SET "ownerId" = '' WHERE "ownerId" = '' AND CHECKSUM NOT IN (SELECT CHECKSUM FROM assets WHERE "ownerId" = ''); + +-- reassign external libraries +UPDATE libraries SET "ownerId" = '' WHERE "ownerId" = ''; ``` 4. There might be left-over assets in the 'source' user's library if they are skipped by the last query because of duplicate checksums. These are probably duplicates anyway, and can probably be removed.