LoginSignup
2
4

More than 5 years have passed since last update.

[備忘録]Herokuのデータベースの中身を手元にコピーする

Posted at

ほとんどリファレンスにある通りなんだけど、自分用

下準備

データベースの初期化
$ bundle exec rake db:migrate:reset

bundle exec rake db:reset でも可。テーブルの作成をschemaファイルから作るのか、マイグレーションファイルから作るのかの違い。

Heroku上のデータベースのバックアップの作成、ダウンロード

完全にリファレンス通り

$ heroku pg:backups:capture
$ heroku pg:backups:download

手元のテーブルにデータの流し込み 

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump

これもリファレンス通り、 myusermydb の部分を適宜書き換える。 config/database.yml を参考に。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4