38
votes

I am trying to view my Heroku app's schema in Terminal (Mac OS X Lion) and stumbled upon a command that does just that. In Terminal, I run heroku run more db/schema.rb but it seems to display an older schema version. I just migrated the Heroku db and I noticed that none of the new columns are listed.

I can't seem to find anything helpful in Heroku's documentation. Does anyone know a command to view the current database schema for a Heroku app?

By the way, I inherited the code for the app and for some reason all of the migration files are commented out (there are probably 40+ files) so I can't just run rake db:migrate locally to update the schema; hence, I'd like to see the Heroku app's schema directly.

Any suggestions?

3

3 Answers

77
votes

You could run heroku pg:psql to fire up a Postgres console, then issue \d to see all tables, and \d tablename to see details for a particular table.

32
votes

For a rails schema, try:

$ heroku run "bundle exec rake db:schema:dump && cat db/schema.rb"
1
votes

You can use rateaux:

rake db:view:schema