openpim / server

Apache License 2.0
58 stars 24 forks source link

Issue related to init.sql causing Node server to error out: column "order" does not exist #23

Closed ealemda2 closed 7 months ago

ealemda2 commented 8 months ago

Steps to recreate:

Upon looking at the logs in server.log docker-compose logs openpim you can see that the server errors out with:

node:internal/process/promises:279
openpim-1  |             triggerUncaughtException(err, true /* fromPromise */);
openpim-1  |             ^
openpim-1  |
openpim-1  | Error
openpim-1  |     at Query.run (/server/node_modules/sequelize/lib/dialects/postgres/query.js:50:25)
openpim-1  |     at /server/node_modules/sequelize/lib/sequelize.js:313:28
...
...
  original: error: column "order" does not exist
openpim-1  |       at Parser.parseErrorMessage (/server/node_modules/pg-protocol/dist/parser.js:287:98)
openpim-1  |       at Parser.handlePacket (/server/node_modules/pg-protocol/dist/parser.js:126:29)
openpim-1  |       at Parser.parse (/server/node_modules/pg-protocol/dist/parser.js:39:38)
openpim-1  |       at Socket.<anonymous> (/server/node_modules/pg-protocol/dist/index.js:11:42)
openpim-1  |       at Socket.emit (node:events:513:28)
openpim-1  |       at addChunk (node:internal/streams/readable:315:12)
openpim-1  |       at readableAddChunk (node:internal/streams/readable:289:9)
openpim-1  |       at Socket.Readable.push (node:internal/streams/readable:228:10)
openpim-1  |       at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {

This is due to a table reference issue in init.sql. The issue was fixed when I changed the last two ALTER TABLE references from "actions" and "references" to public."actions" and public."references" like below:

ALTER TABLE public."actions" 
    ADD COLUMN "order" integer;

ALTER TABLE public."savedSearch" 
    ADD COLUMN "entity" varchar(50);
ealemda2 commented 8 months ago

After the fix you can run docker-compose down and docker-compose up --force-recreate -d to have the server working.

The openpim logs should now look like this:

Check: http://www.postgresql.org/docs/9.4/static/datatype.html
openpim-1  | 2024/03/28 09:05:14.525 [info]:  Serverversion: 2.0.240108392
openpim-1  | 2024/03/28 09:05:14.525 [info]:  Arguments: /usr/local/bin/node,/server/dist/src/index.js
openpim-1  | 2024/03/28 09:05:14.631 [info]:  RunningaGraphQLAPIserver at http://localhost:8080/graphql
openpim-1  | 2024/03/28 09:05:14.649 [info]:  Data models were loaded

Also, sometimes on the first docker-compose up --force-recreate -d, my openpim logs give the error: Error: connect ECONNREFUSED 172.31.0.2:5432. This issue strangely is fixed when I run docker-compose up --force-recreate -d again while the containers are already up and running.

openpim commented 7 months ago

This is old version of sql script, please use version that is described at our site image

openpim commented 7 months ago

https://www.openpim.org/index.html#getstarted

ealemda2 commented 7 months ago

@openpim Thanks for the response. Why doesn't the init.sql file referenced in the link match the one in the master branch? Does the master branch not include the most up to date code?