postgresql - "No relations found" in psql after rails db:migrate succeeds -
as rails novice, i'm following instructions in railscast #342 set postgres database connection on mac.
i created new rails project
$ rails new blog -d postgresql
i edited database yaml file set username , password.
i used psql add new user , password, , gave permission create tables: alter user blog create db
i created db via
rake db:create:all
it succeeded , inside psql, doing \l list schemas, see 3 schemas blog_test, blog_development , blog_production
i do
$ rails g scaffold article name content:text
all looks good
i do
$ rake db:migrate
i messages showing success:
$ rake db:migrate == 20150701220010 createarticles: migrating =================================== -- create_table(:articles) -> 0.0128s == 20150701220010 createarticles: migrated (0.0129s) ==========================
i set search path @ schema:
set search_path lcuff,public,blog_development;
show search_path:
search_path --------------------------------- lcuff, public, blog_development
but trying find table,
# \d
no relations found.
i've done db:migrate version=0
, reports drops table, , create again db:migrate
, reports success.
if first part hadn't worked, created schema, i'd think i'm pointed wrong database somehow.
ideas?
you should first connect database before fetching tables.
\connect blog_development
and try giving \d
list tables.
you can try \dt
.
example(tested in project):
\connect my_db connected database "my_db" user "postgres". my_db=# \d list of relations schema | name | type | owner --------+-------------------------------+-------+---------- public | access_managements | table | postgres public | amenities | table | postgres public | city_coordinates | table | postgres public | coapplicants | table | postgres
Comments
Post a Comment