horizon icon indicating copy to clipboard operation
horizon copied to clipboard

Unable to call horizon db init with --db-url parameter

Open vogel opened this issue 8 years ago • 3 comments

I was unable to init horizon db with --db-url parameter:

/horizon db init --db-url="postgres://localhost/horizon" Error: unknown flag: --db-url Run 'horizon help' for usage.

vogel avatar Oct 05 '16 15:10 vogel

Confirmed. As a workaround you can use env variable:

DB_URL="postgres://localhost/horizon" ./bin/horizon db init

bartekn avatar Oct 05 '16 15:10 bartekn

Great catch: The issue is related to the fact that we don't make the flags "persistent" in cobra terms: https://github.com/stellar/horizon/blob/master/src/github.com/stellar/horizon/cmd/horizon/main.go#L62

Should be pretty simple to fix.

nullstyle avatar Oct 05 '16 17:10 nullstyle

Just hit this bug too. For future reference the environment variable you need to set is DATABASE_URL and not DB_URL

Unix domain socket
DATABASE_URL="dbname=horizon user=stellar host=/var/run/postgresql" horizon db init
TCP connection
DATABASE_URL="postgres://localhost/horizon" horizon db init

brahman81 avatar Dec 12 '17 09:12 brahman81