boramalper / magnetico

Autonomous (self-hosted) BitTorrent DHT search engine suite.
http://labs.boramalper.org/magnetico/
GNU Affero General Public License v3.0
3.06k stars 344 forks source link

Failed when using different schema on postgresql #273

Open kehboard opened 3 years ago

kehboard commented 3 years ago

When I set schema in connection URI, program crashed. ~/go/bin/magneticod --database=postgres://user:pass@127.0.0.1/magneticod\?sslmode\=disable\&schema\=magneticod -v 2021-05-08T17:56:07.029+0300 INFO magneticod v0.12.0 has been started. 2021-05-08T17:56:07.030+0300 INFO Copyright (C) 2017-2020 Mert Bora ALPER <bora@boramalper.org>. 2021-05-08T17:56:07.030+0300 INFO Dedicated to Cemile Binay, in whose hands I thrived. 2021-05-08T17:56:07.030+0300 INFO Compiled on 2021-05-08T14:52:25Z 2021-05-08T17:56:07.040+0300 FATAL Could not open the database {"url": "postgres://user:pass@127.0.0.1/magnet?sslmode=disable&schema=magnet", "error": "sql.DB.Ping: failed to connect to host=127.0.0.1 user=magnetico database=magnet: server error (FATAL: unrecognized configuration parameter \"schema\" (SQLSTATE 42704))", "errorVerbose": "failed to connect to host=127.0.0.1 user=magnetico database=magnet: server error (FATAL: unrecognized configuration parameter \"schema\" (SQLSTATE 42704))\nsql.DB.Ping\ngithub.com/boramalper/magnetico/pkg/persistence.makePostgresDatabase\n\t/home/user/magnetico-0.12.0/pkg/persistence/postgres.go:45\ngithub.com/boramalper/magnetico/pkg/persistence.MakeDatabase\n\t/home/user/magnetico-0.12.0/pkg/persistence/interface.go:120\nmain.main\n\t/home/user/magnetico-0.12.0/cmd/magneticod/main.go:95\nruntime.main\n\t/usr/lib/go-1.16/src/runtime/proc.go:225\nruntime.goexit\n\t/usr/lib/go-1.16/src/runtime/asm_amd64.s:1371"} If I remove parameter schema from connection URI it creates schema "magneticod" but that scheme empty and all data saved in "public" scheme. all schemas in db empty schema magneticod public scheme

skobkin commented 3 years ago

Strange.

https://github.com/boramalper/magnetico/blob/9c2183b91b5b37560607d1ebf98cfd1b542cfc27/pkg/persistence/postgres.go#L29-L33

FATAL: unrecognized configuration parameter \"schema\"

Needs to be checked.