ghostfolio / ghostfolio

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
https://Ghostfol.io
GNU Affero General Public License v3.0
3.85k stars 362 forks source link

Accessing database when self-hosting (Finalization) #660

Closed sueskind closed 2 years ago

sueskind commented 2 years ago

I am trying to follow the setup steps in the README. However, as I have only basic knowledge of docker(-compose) and PostgreSQL, I was not able to do the "Finalization" steps (namely accessing the database).

In issue #635 basically the same question is raised but when I follow the steps of the answer I get the following error when doing docker-compose exec postgres psql -U user in the docker directory:

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "user" does not exist

What am I missing?

dtslvr commented 2 years ago

Hi @sueskind

Can you please try to run the command as follows: docker-compose exec postgres psql -U user ghostfolio-db

sueskind commented 2 years ago

Thank you, this got me to a prompt where I could issue the remaining commands. However, I can still login with the Admin token after performing the last two steps, this should not be possible, right?

Namely, I did:

dtslvr commented 2 years ago

Did you get any feedback message after running the commands?

  • UPDATE "User" SET "role" = 'ADMIN WHERE "provider" = 'ANONYMOUS';

Here is a typo: the single quote after ADMIN is missing

sueskind commented 2 years ago

Yes, that was it. I was just copy-pasting the command without checking them...

However, there seem to be multiple foreign key constraints which make directly running the DELETE command impossible. Maybe there should be a better way to delete the default Admin user?

Anyway, I am closing this now as you answered my original question, thank you very much.

dtslvr commented 2 years ago

Yes, that was it. I was just copy-pasting the command without checking them...

@sueskind I am glad it worked out 😃

A better way than deleting the default Admin user could be to not seed an Admin user, but automatically create the first user as an Admin if there is no one in the database yet. What do you think?