Issues with database schema migrations

Hi, I set up lora and lora-app-server in windows. Both services run without errors on the same PC. In the LoRa server app I try to enter the a network server (no entries yet).
Everytime I get the Error rpc error: code = Unknown desc = pq: Relation »routing_profile« existiert nicht (code: 2)

It doesn’t matter if I enter 127.0.0.1:8000, localhost:8000, DNS or IP of the computer.

Log entries:

LORA Server

INFO[0000] starting LoRa Server                          band="EU_863_870" docs="https://docs.loraserver.io/" net_id=010203 version=0.23.1
INFO[0000] setup redis connection pool                   url="redis://localhost:6379"
INFO[0000] connecting to postgresql
INFO[0000] backend/gateway: connecting to mqtt broker    server="ssl://workstation:8884"
INFO[0000] setup application-server client pool          ca_cert= tls_cert= tls_key=
INFO[0000] configuring join-server client                ca_cert= server="http://localhost:8003" tls_cert= tls_key=
INFO[0000] backend/gateway: connected to mqtt server
INFO[0000] backend/gateway: subscribing to rx topic      topic="gateway/+/rx"
INFO[0000] no network-controller configured
INFO[0000] starting api server                           bind="0.0.0.0:8000" ca-cert= tls-cert= tls-key=
INFO[0000] starting gateway api server                   bind="0.0.0.0:8002" ca-cert= tls-cert= tls-key=
INFO[0000] starting downlink device-queue scheduler
INFO[0000] backend/gateway: subscribing to stats topic   topic="gateway/+/stats"
ERRO[0000] class-c scheduler error                       error="get deveuis with class-c device-queue items error: select error: pq: Relation »device« existiert nicht"

LoRa App Server

INFO[0000] starting LoRa App Server                      docs="https://docs.loraserver.io/" version=0.16.0
INFO[0000] connecting to postgresql
INFO[0000] setup redis connection pool
INFO[0000] handler/mqtt: connecting to mqtt broker       server="ssl://workstation:8884"
INFO[0000] applying database migrations
INFO[0000] handler/mqtt: connected to mqtt broker
INFO[0000] handler/mqtt: subscribling to tx topic        topic="application/+/node/+/tx"
INFO[0000] migrations applied                            count=0
INFO[0000] starting application-server api               bind="0.0.0.0:8001" ca-cert= tls-cert= tls-key=
INFO[0000] starting join-server api                      bind="0.0.0.0:8003" ca_cert= tls_cert= tls_key=
INFO[0000] starting client api server                    bind="0.0.0.0:8080" tls-cert="c:\lora\server.crt" tls-key="c:\lora\server.key"
INFO[0000] registering rest api handler and documentation endpoint  path="/api"
ERRO[0123] network-server create routing-profile api error  error="rpc error: code = Unknown desc = pq: Relation »routing_profile« existiert nicht"

The services are startes with following options:

loraserver
--net-id 010203 
--band EU_863_870 
--gw-server-jwt-secret Vn0DfnL3QyUHUNUeETjPBvKPJ3GOdnxtsRDakIPnXdY= 
--postgres-dsn postgres://loraserver_ns:loraserver_ns@localhost/loraserver_ns?sslmode=disable 
--gw-mqtt-server ssl://workstation:8884 
--gw-mqtt-ca-cert %pfadLora%\ca.crt 
--bind 0.0.0.0:8000 
--gw-server-bind 0.0.0.0:8002 
--js-server http://localhost:8003 
--log-node-frames true 
--db-automigrate 
--gw-create-on-stats 
--gw-stats-aggregation-intervals "minute,hour,day"
--log-level 1 
--version

lora-app-server
--postgres-dsn postgres://loraserver:loraserver@localhost/loraserver?sslmode=disable 
--mqtt-server ssl://workstation:8884 
--mqtt-ca-cert %pfadLora%\ca.crt 
--jwt-secret VX0DfnL3QyUHUNUeETjPBvKPJ3GOdnxtsRDakIPnXdY= 
--db-automigrate 
--http-tls-cert %pfadLora%\server.crt 
--http-tls-key %pfadLora%\server.key 
--as-public-server localhost:8001 
--as-public-id 6d5db27e-4ce2-4b2b-b5d7-91f069397978 
--bind 0.0.0.0:8001 
--http-bind 0.0.0.0:8080 
--js-bind 0.0.0.0:8003 

Has someone an idea what the problem could be? Thanks for help!

Hi, the errors indicate that tables “device” and “routing_profile” don’t exist at the loraserver end, i.e., in the “loraserver_ns” DB as your DSN states. I see that in your config --db-automigrate is set, but I don’t see that migrations were applied on loraserver start as they do in lora-app-server, where you can see this:

INFO[0000] migrations applied count=0

So maybe you missed the option, mistyped it or something like that.

I’ve renamed the topic to “Issues with database schema migrations” as this is not specific to routing-profiles.

@sosi best would be to inspect the content of gorp_migrations in each database. That table contains the history of all the appplied database-migrations.