0

I'm trying to set up postgREST. Have been following the tutorial at http://postgrest.org/en/v5.1/tutorials/tut0.html. Here is what I see. First, the schemas:

entercarlson=# \dn
List of schemas
Name  |  Owner
--------+---------
api    | carlson
public | carlson

Then a table:

carlson=# \d api.todos
                                        Table "api.todos"
 Column |           Type           | Collation | Nullable |                Default
--------+--------------------------+-----------+----------+---------------------------------------
 id     | integer                  |           | not null | nextval('api.todos_id_seq'::regclass)
 done   | boolean                  |           | not null | false
 task   | text                     |           | not null |
 due    | timestamp with time zone |           |          |
Indexes:
    "todos_pkey" PRIMARY KEY, btree (id)

Finally, some data:

carlson=# select * from api.todos;
 id | done |       task        | due
----+------+-------------------+-----
  1 | f    | finish tutorial 0 |
  2 | f    | pat self on back  |
(2 rows)

But then I get this:

$ curl http://localhost:3000/todos
{"hint":null,"details":null,"code":"42P01","message":"relation 
 \"api.todos\" does not exist"}

Which is consistent with this:

carlson=# \d
Did not find any relations.

What am I doing wrong?

PS. I don't see which database this schema belongs to

jxxcarlson
  • 223
  • 3
  • 13
  • What value are you using for "db-schema" in the postgrest configuration file? It should be "api" to match where you're storing the tables. http://postgrest.org/en/v5.1/install.html#configuration – Joe Nelson Dec 07 '18 at 19:22

1 Answers1

1

Seems you're targeting the wrong database, check the db-uri config value and make sure this uri contains the api.todos table through psql.

Also, want to clarify that the search_path is modified by PostgREST on each request, so if you ALTER your connection user search_path it'll have no effect on the schemas PostgREST searches.

Steve Chavez
  • 931
  • 10
  • 13