subzerocloud / postgrest-starter-kit

Starter Kit and tooling for authoring REST API backends with PostgREST
MIT License
744 stars 71 forks source link

Code reload not working #19

Closed steve-mt closed 7 years ago

steve-mt commented 7 years ago

Hello, thank you for open sourcing this project it is quite interesting and I want to learn more about it. I am facing some issues regarding the code reload, as described below.

Every time I do a change in data db/src/sample_data/data.sql as a specified here the stack breaks down. I start getting the following errors

OpenResty

│./db/src/sample_data/data.sql changed                                                                                                                                                                                                                                         │
│Starting code reload ------------------------                                                                                                                                                                                                                                 │
│Ready ---------------------------------------                                                                                                                                                                                                                                 │
│sed: /docker-entrypoint-initdb.d/libs/pgjwt/pgjwt-0.0.1.sql: No such file or directory                                                                                                                                                                                        │
│psql:/Users/steveazzopardi/Code/github.com/SteveAzz/khumbuicefall/db/src/libs/auth/schema.sql:27: ERROR:  function pgjwt.sign(json, text) does not exist                                                                                                                      │
│LINE 2:     select pgjwt.sign($1, settings.get('jwt_secret'))

pg-amqp-bridge

│thread '<unnamed>' panicked at 'internal error: entered unreachable code', /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/postgres-0.14.2/src/notification.rs:155:17                                                                                            │
│note: Run with `RUST_BACKTRACE=1` for a backtrace.

curl

$ curl -H "Authorization: Bearer $JWT_TOKEN" "http://localhost:8080/rest/todos?select=id,todo"
{"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"}⏎

I am running on latest master. Macos, latest stable docker version

ruslantalpa commented 7 years ago

sorry for the late reply, is this happening on a clean/new clone or did you change something in the init.sql file

steve-mt commented 7 years ago

Hello, sorry for the late reply myself. Yes, it was.

ruslantalpa commented 7 years ago

it works for me, here is a complete list of things i did from a clean dir


~/tmp$ mkdir example-api
~/tmp$ cd example-api
~/tmp/example-api$ git init
Initialized empty Git repository in /Users/ruslantalpa/tmp/example-api/.git/
~/tmp/example-api$ git remote add upstream https://github.com/subzerocloud/postgrest-starter-kit.git
~/tmp/example-api$ git fetch upstream
remote: Counting objects: 470, done.
remote: Total 470 (delta 0), reused 0 (delta 0), pack-reused 470
Receiving objects: 100% (470/470), 1.10 MiB | 184.00 KiB/s, done.
Resolving deltas: 100% (183/183), done.
From https://github.com/subzerocloud/postgrest-starter-kit
 * [new branch]      master     -> upstream/master
~/tmp/example-api$ git merge upstream/master
~/tmp/example-api$ docker-compose up -d
WARNING: The MAX_ROWS variable is not set. Defaulting to a blank string.
WARNING: The PRE_REQUEST variable is not set. Defaulting to a blank string.
Creating postgreststarterkit_db_1 ... 
Creating postgreststarterkit_rabbitmq_1 ... 
Creating postgreststarterkit_rabbitmq_1
Creating postgreststarterkit_db_1 ... done
Creating postgreststarterkit_postgrest_1 ... 
Creating postgreststarterkit_rabbitmq_1 ... done
Creating postgreststarterkit_pg_amqp_bridge_1 ... 
Creating postgreststarterkit_postgrest_1 ... done
Creating postgreststarterkit_openresty_1 ... 
Creating postgreststarterkit_openresty_1 ... done
~/tmp/example-api$ curl http://localhost:8080/rest/todos?select=id,todo
{"message":"Database connection lost, retrying the connection."}~/tmp/example-api$ 
~/tmp/example-api$ curl http://localhost:8080/rest/todos?select=id,todo
[{"id":1,"todo":"item_1"},{"id":3,"todo":"item_3"},{"id":6,"todo":"item_6"}]~/tmp/example-api$ 

#####
this is where in another terminal window i executed
subzero dashboard

then changed item_1 to item_1 update
saved the file, then saw this in subzero cli
./db/src/sample_data/data.sql changed                                                                                                                                           Starting code reload ------------------------                                                                                                                                   Ready ---------------------------------------
#####
after getting back to the first window, i reexecuted the call and got the correct response

~/tmp/example-api$ curl http://localhost:8080/rest/todos?select=id,todo
[{"id":1,"todo":"item_1_update"},{"id":3,"todo":"item_3"},{"id":6,"todo":"item_6"}]~/tmp/example-api$
ruslantalpa commented 7 years ago

make sure you have the latest subzero-cli https://github.com/subzerocloud/subzero-cli

steve-mt commented 7 years ago

The issue seems to be because of me forgetting to install sqitch I'm sorry for wasting your time.

Thank you so much for helping me and for the hard work you put into this project 💯