New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Database migration error while installing Ghostfolio on Unraid #1395
Comments
Have you seen this error before @LeonStoldt? |
No, i haven't - but I also did not execute a fresh installation for some time now (e.g. including the auto database migration in docker image). @framewerktechnologies just to prevent misunderstanding: It's weird, because the problem not being able to edit an enum in the transaction block - most likely "caused" by this line in the mentioned migration script: -- AlterEnum
ALTER TYPE "AccountType" ADD VALUE 'CASH'; cannot be a general problem - based on my understanding. If it would be, it would fail everytime you are executing a fresh migration, but this never happened to me. So i would exclude a general issue in the migration (script) structure. If it's a transaction thing, maybe there's a way to tell prisma how to handle transaction while applying these migrations? I'm not familiar with prisma. @dtslvr is there something like "commit after every migration step"? - just looking for a quick fix here. Maybe, I would try to apply the script manually one by one. This link should help with prisma commands. A more "ugly" way would be to connect to your postgres (right click postgres, console and type something like: -- Type: AccountType
--DELETE
DROP TYPE public."AccountType";
CREATE TYPE public."AccountType" AS ENUM
('CASH', 'SECURITIES');
--optinal change owner to your ghostfolio owner
ALTER TYPE public."AccountType"
OWNER TO ghostfolio;
--second step in migration script
ALTER TABLE "Account" ADD COLUMN "balance" DOUBLE PRECISION NOT NULL DEFAULT 0,
ADD COLUMN "currency" "Currency" NOT NULL DEFAULT E'USD'; and mark that migration step as already applied with something like this: npm prisma migrate resolve --applied "20210703194509_added_balance_to_account" However, it should work out of the box and it's not the best way to start with a crappy database. I will try installing it on a fresh system and try to reproduce the error. |
Thank you very much for your detailed explanations @LeonStoldt.
I can confirm that nothing has changed in the migration concept recently. |
Good morning gents, I just wanted to add my report to this issue - I just tried installing a fresh Ghostfolio instance on Unraid as well, with Postgres and Redis from the Unraid app store. I hit the exact same issue as @framewerktechnologies did. Dropped the database and tried again, with the same result. Hoping there's a better fix than hacking the migration script... but if not I'll go ahead with that. |
Any ideas on a work around. I am strugging to get this installed on unraid . Fresh install. I went back to 1.190.0 and a fresh install empty DB is is still broke. The docker container stops so I can get the npm command to execute |
I figured this out for anyone that wants to know I did sql steps above manually while the docker was stopped by connecting to the postsql db with adminer. Then I went into the migration record that failed and marked it complete (added a completion date). Restarted docker and the DB build. I was able to log in and get started. Ran into another problem pulling prices and historical data, solved that by setting a TZ variable to null |
Hi everyone, I wrote down the docker commands Unraid executed when creating the container via template. Maybe this could be helpful to start it via console (needs some changes in the parameters to fit your setup of course): Docker commandsOpen your unraid terminal in the top-right-hand corner to execute the following commands:
docker run \
-d \
--name='postgresql15-ghostfolio' \
--net='bridge' \
-e TZ="Europe/Berlin" \
-e HOST_OS="Unraid" \
-e HOST_HOSTNAME="Server" \
-e HOST_CONTAINERNAME="postgresql15-ghostfolio" \
-e 'POSTGRES_PASSWORD'='password' \
-e 'POSTGRES_USER'='ghostfolio' \
-e 'POSTGRES_DB'='ghostfolio-db' \
-l net.unraid.docker.managed=dockerman \
-l net.unraid.docker.icon='https://github.com/juusujanar/unraid-templates/raw/master/img/PostgreSQL-logo.png' \
-p '5432:5432/tcp' \
-v '/mnt/cache/appdata/postgresql15':'/var/lib/postgresql/data':'rw' 'postgres:15'
docker run \
-d \
--name='Redis-ghostfolio' \
--net='bridge' \
-e TZ="Europe/Berlin" \
-e HOST_OS="Unraid" \
-e HOST_HOSTNAME="Server" \
-e HOST_CONTAINERNAME="Redis-ghostfolio" \
-l net.unraid.docker.managed=dockerman \
-l net.unraid.docker.icon='https://raw.githubusercontent.com/juusujanar/unraid-templates/master/img/Redis-logo.png' \
-p '6379:6379/tcp' 'redis'
docker run \
-d \
--name='Ghostfolio' \
--net='bridge' \
-e TZ="Europe/Berlin" \
-e HOST_OS="Unraid" \
-e HOST_HOSTNAME="Server" \
-e HOST_CONTAINERNAME="Ghostfolio" \
-e 'REDIS_HOST'='redis.local' \
-e 'REDIS_PORT'='6379' \
-e 'DATABASE_URL'='postgresql://ghostfolio:password@postgres.local:5432/ghostfolio-db?sslmode=prefer' \
-e 'BASE_CURRENCY'='USD' \
-e 'REDIS_PASSWORD'='' \
-e 'ALPHA_VANTAGE_API_KEY'='' \
-e 'EOD_HISTORICAL_DATA_API_KEY'='' \
-e 'JWT_SECRET_KEY'='123456' \
-e 'ACCESS_TOKEN_SALT'='GHOSTFOLIO' \
-e 'NODE_ENV'='production' \
-l net.unraid.docker.managed=dockerman \
-l net.unraid.docker.webui='http://[IP]:[PORT:3333]' \
-l net.unraid.docker.icon='https://avatars.githubusercontent.com/u/82473144?s=200' \
-p '3333:3333/tcp' 'ghostfolio/ghostfolio' and my logs from initial start until gathering some example data looks like this: |
I know this is an old issue however I was running into the same error. I was trying to run it on Postgres 11 (an old installation that I need to migrate off of eventually). However after searching for the exact error I came across this on stack overflow "error: ALTER TYPE ... ADD cannot run inside a transaction block". Upgrading to a newer version of Postgres fixed it. |
Bug Description
While installing Ghostfolio on my Unraid server via docker, database migration errors are occurring.
To Reproduce
ERROR: ALTER TYPE ... ADD cannot run inside a transaction block
Expected behavior
The app shouldn't have issues during the DB migration.
Screenshots
Logs
Environment
Additional context
Unraid uses the official Docker image.
The text was updated successfully, but these errors were encountered: