how to execute a .sql script on heroku?

后端 未结 4 545
醉梦人生
醉梦人生 2020-12-12 13:02

I have a .sql file with a bunch of insert commands that I want to execute on my postgres database on heroku. But I don\'t know how to do it:-

If I had access to post

4条回答
  •  一生所求
    2020-12-12 13:21

    I like updates that are testable and repeatable. When I need to update the database I write a rake task to perform the update; that way you can run it against test first to guarantee the output is correct before running in production.

    You don't mention if this is an initial database load or one run later, but the convention for loading fresh data into a Rails database is to create a db:seed rake file that you can execute after your db:migrate task is done.

    See: http://justinfrench.com/notebook/a-custom-rake-task-to-reset-and-seed-your-database And: http://railscasts.com/episodes/179-seed-data

提交回复
热议问题