Is there a simple way to visualize the tables that are created for postgres databases in Heroku? I am trying to see what columns have been for my Rails app without having to go through all of my database migrations.
2 Answers
To view your tables you can run heroku pg:psql to fire up a Postgres console. Then just type \d to view your tables or if you want to get details from a particular table just run \d tablename.
Or, as @jvillian suggested you can view your schema.rb file that's deployed to your Heroku server.
$ heroku run bash
$ cat db/schema.rb
5 Comments
NoMethodError so I infer my tables are messed up..." Doesn't quite sound right, y'know?heroku pg:psql to view them would help right? he then just needs to compare what tables are migrated against his local environment.NoMethodError (undefined method 'titleize' for nil:NilClass). That's a missing data problem. Not a missing table/field problem. Or am I thinking about that wrong?missing relation error at the DB level. Missing column would give unknown attribute error. Or some such things. But, not the error he's getting.I found that the easiest way to solve this problem is to do heroku pg:psql and then do \d users to look at my table named "users". It turns out I have migrated the columns first_name and last_name, so I have solved the problem I posted about.
I'm still trying to figure out why I am running into the NoMethodError (undefined method 'titleize' for nil:NilClass). If you are having trouble with this issue and this answer does not help you, check out the comments between jillian and Cyzanfar. They have good insights into how a postgres database works with Heroku.
schema.rbfile. That is, assuming your local db and Heroku db are migrated to the same state.heroku run:detached rake db:migratewhich ends up not creating all of the columns I want.NoMethodError (undefined method 'titleize' for nil:NilClass)when I am trying to titleize user's first and last names. This is working in my development environment, but not in production which is leading me to think that the schema files are different.