Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view current database schema for Heroku app in Terminal?

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?

like image 204
vich Avatar asked Apr 11 '13 15:04

vich


People also ask

How do I view my Heroku database?

You can find them by visiting the Resources tab on your Dashboard then clicking on the DB you use. It will take you to the Addons page in another tab. Click on the Settings tab then View Credentials. Using these credentials, you can use Adminer to login to the DB.

How can I see my table in Heroku Postgres?

From the application dashboard on Heroku, go to the 'resources' tab and search for postgres. Provision it and use the free option. There's now a clickable link to the Datastore associated with your application. Go ahead and open the link to your datastore, and take note of exactly how to get here again.


1 Answers

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.

like image 166
Chowlett Avatar answered Sep 16 '22 16:09

Chowlett