konga icon indicating copy to clipboard operation
konga copied to clipboard

Add flag or feature to create database if not exist when running prepare command

Open fatahnuram opened this issue 4 years ago • 2 comments

Hi I'm running konga with docker image pantsel/konga:next and deploy it on top of kubernetes and running against fresh clean database (using postgres).

When I'm running with this command:

-c prepare -a postgres -u postgresql://${KONG_DB_USER}:${KONG_DB_PASSWORD}@${KONG_DB_HOST}:5432/konga_db

It gives me error like this:

...

error: A hook (`orm`) failed to load!
error: Failed to prepare database: error: database "konga_db" does not exist
    at Connection.parseE (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
    at Socket.emit (events.js:310:20)
    at Socket.EventEmitter.emit (domain.js:482:12)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

Based on error logs seems like I need to create the database manually first, and then I'm creating that. After that I run the prepare again and it was running successfully.

So can we add a flag (something like environment variable or maybe another command or kind of it) so that the user can create the database when running the prepare script? I really like the prepare option but tbh I hate it when it comes with manual intervention :slightly_frowning_face:

All I want is just scripted actions :slightly_smiling_face:

Thank you

fatahnuram avatar Feb 08 '21 14:02 fatahnuram

Also I'm happy if I can help you with the feature I'm talking about :slightly_smiling_face:

fatahnuram avatar Feb 08 '21 14:02 fatahnuram

If you are using docker-compose just add your database to kong-database service:

kong-database: image: postgres:9.6 container_name: kong-database ports: - 5432:5432 environment: - POSTGRES_USER=kong - POSTGRES_DB=kong,konga_db - POSTGRES_PASSWORD=kong

Hicham-Chahboune avatar Jun 06 '23 09:06 Hicham-Chahboune