"No relationship found" in psql after rails db: migrate successs
As a Rails newbie I follow the instructions in railscast # 342 to set up a postgres database connection on my Mac.
I created a new rails project with
$ rails new blog -d postgresql
I edited the database yaml file to set the username and password.
I used psql to add a new user and password and gave it permission to create tables: alter user blog create db
I created a db via
rake db:create:all
This succeeded inside psql too, doing \ l to list the schemas, I can see all three schemas blog_test, blog_development and blog_production
Then i do
$ rails g scaffold article name content:text
everything looks good
Then i do
$ rake db:migrate
I am getting messages showing success:
$ rake db:migrate
== 20150701220010 CreateArticles: migrating ===================================
-- create_table(:articles)
-> 0.0128s
== 20150701220010 CreateArticles: migrated (0.0129s) ==========================
I set my search path to look at the diagram:
set search_path to lcuff,public,blog_development;
show search_path:
search_path
---------------------------------
lcuff, public, blog_development
But trying to find a table,
# \d
No relationship found.
I did db:migrate VERSION=0
and it successfully reports that it is dropping the table and then re-creating it with db:migrate
and reports success.
If the first part didn't work, where it actually created the schema, I think I pointed to the wrong database somehow.
Ideas?
source to share
Before fetching tables, connect to the database first .
\connect blog_development
And then try giving a \d
list of all tables.
You can also try with \dt
.
Example (tested in my project):
\connect my_db
You are now connected to database "my_db" as 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
source to share