Forest schema:update - cannot connect to database

Hi,
I am trying your forest-cli and it looks nice. I see all tables in admin that were present in database by initial launch of forest admin. However, I am not able to update schema, actually, I think I don’t have any.

So this is how I proceeded:

  1. Datasource is PostgreSQL
  2. I have installed admin with docker and docker container is running.
  3. I have installed npm install --global forest-cli
  4. E.g. login with forest login is working properly.
  5. My project qms-forest displays all initial data

Now I made some changes in database and I would like to update schema, so the changes are visible in forest admin, what should I do for that please?

I tried forest schema:update, but I am getting error

The liana is incompatible for update: Your project is not compatible with the lforest schema:updatecommand. You need to use an agent version greater than 7.0.0.

Thank you

Vaclav

Hi @Vaclav :wave:
Can you share with us the package.json, more precisely this line "forest-express-sequelize": ..., in the folder where you ran the forest schema:update command.

Hi @Arnaud_Moncel,

I was thinking to describe also my folder structure, this is how it looks.
Folder tm-qms-api → root folder of the whole project
/node_modules
/package.json
/ src
/test

/qms-forest → this is subfolder where forest admin backend is installed
/qms-forest/package.json

  1. So at the beginning, I have installed "forest-express-sequilize": "^8.0.8" in qms-forest/package.json
  2. When I tried to run forest schema:update, I got an error:
    Cannot connect to the database due to the following error: × SequelizeHostNotFoundError: getaddrinfo ENOTFOUND host.docker.internal
  3. So I tried to run that one level up direct in the folder tm-qms-api
  4. Here I was getting that error: The liana is incompatible for update: Your project is not compatible with the "lforest schema:update" command. You need to use an agent version greater than 7.0.0.
  5. I didn’t have installed "forest-express-sequilize": "^8.0.8" in tm-qms-api/package.json at that time and I was thinking maybe this is the issue…
  6. I installed "forest-express-sequilize": "^8.0.8" in tm-qms-api/package.json. Previously it was just in tm-qms-api/qms-forest/package.json
  7. I ran once more npm install --global forest-cli

Now it behaves as following:

  1. I run forest schema:update in folder tm-qms-api/qms-forest
    ERROR:
    × Cannot connect to the database due to the following error:
    × SequelizeHostNotFoundError: getaddrinfo ENOTFOUND host.docker.internal

  2. I run forest schema:update in folder tm-qms-api
    ERROR:
    × We are not able to detect a Forest CLI project file architecture at this path: /Users/vaclav/javascript/tm-qms-api.: Error: No “routes” directory.

So back to your question, both package.json files have the version "forest-express-sequelize": "^8.0.8"

Thank you for your help Arnaud.

Best regards,

Vaclav

Hey @Vaclav :wave:

Your step 1 is the way to go. forest-cli needs to be run in the directory with the package.json containing the "forest-express-sequelize": "^x.y.z",.

forest-cli will then check if your folder structure is correct, then try to connect to your database.

The fact that you are getting the Cannot connect to the database due to the following error: × SequelizeHostNotFoundError: getaddrinfo ENOTFOUND host.docker.internal error seems to indicate that forest-cli is not able to contact host.docker.internal - which should be the case in a docker context.

From what I can read in the thread, you are using a full docker setup, right?
Do you run forest-cli in docker or from your host?
Are they both able to contact host.docker.internal (MacOS or Windows setup), or do you use a system that does not handle this URL?

Let me know :pray:

Hey @jeffladiray,
yes, you are right, I was trying to run forest-cli from host, which is probably not the best way.

This is working fine!
docker run --rm --init -it -v pwd:/usr/src/app -v ~/.forest.d:/usr/src/cli/.forest.d -e TOKEN_PATH="/usr/src/cli" forestadmin/toolbelt:latest schema:update

Thank you for your help @jeffladiray.

Have a nice day,
Vaclav

1 Like