How to view current database schema for Heroku app

2020-05-14 03:39发布

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条回答
狗以群分
2楼-- · 2020-05-14 04:17

You can use rateaux:

rake db:view:schema
查看更多
老娘就宠你
3楼-- · 2020-05-14 04:23

For a rails schema, try:

$ heroku run "bundle exec rake db:schema:dump && cat db/schema.rb"
查看更多
疯言疯语
4楼-- · 2020-05-14 04:28

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.

查看更多
登录 后发表回答