I
Immich3y ago
nkdf.

manually removing assets from database

I have changed mobile apps from fdroid to play store and created duplicates. Unfortunately I'm also the admin user and cannot just purge my account. Please help me with database commands to remove these assets.
6 Replies
Sven
Sven3y ago
Does you have access to the server? With root permissions? Than you can search for the "storage" folder and in the map look up for your user with id then run sudo rm -r ID
Alex Tran
Alex Tran3y ago
@Sven The actions you described will only remove the asset on disk, not in the database
Sven
Sven3y ago
oh im sorry
Alex Tran
Alex Tran3y ago
np I am writing up a short guide for @nkdf. Remove user's related asset in database Please take great care and double check before you run the following commands. This is a destructive operation and you will lose all of the data in the database and on disk. Access database docker container
docker exec -it <postgres_container_id> bash # Example `docker exec -it immich_postgres bash`
docker exec -it <postgres_container_id> bash # Example `docker exec -it immich_postgres bash`
Connect to database
psql -U <user> -d <database> # Example `psql -U immich -d immich`
psql -U <user> -d <database> # Example `psql -U immich -d immich`
Find user id
SELECT id FROM users WHERE email = '<your_email>';
SELECT id FROM users WHERE email = '<your_email>';
Remove asset with user ID
DELETE FROM assets a WHERE a."userId" = 'user-id-above';
DELETE FROM assets a WHERE a."userId" = 'user-id-above';
Remove physical asset * Navigate to the folder where you mounted UPLOAD_LOCATION in docker-compose.yml * Find the folder with the same name as the userId you just deleted * Remove that folder to clear all of the physical asset you have on disk
nkdf.
nkdf.OP3y ago
Thanks for the guide. Looks straightforward enough. I'll give it a shot later and report back. I got the user selected, but when deleting it keeps giving me a hint, perhaps you meant to reference the column "a.userID". My bad on the capitalization. Got it figured out. As usual, your documentation is great
Alex Tran
Alex Tran3y ago
No problem! Cheers!

Did you find this page helpful?