0
Help us understand the problem. What are the problem?

posted at

Heroku でのDBをリセットしシードデーターを投入する手順

この記事の環境
mac OS
Rails 6.0.3
ruby 3.0.1p64

gitの変更内容をherokuにpushsする

 git push heroku step5:master

新たにカラム追加やデータ内容を変更する為。データーベースリセットをする 。

 heroku pg:reset -a myapp

マイグレーション実行

heroku run rake db:migrate

seedデータ投入

heroku run rails db:seed

おまけ
データーベースの詳細が取得できるコマンド
heroku pg -a アプリ名

=== DATABASE_URL
Plan:                  Hobby-dev
Status:                Available
Connections:           1/20
PG Version:            14.2
Created:               2022-04-11 15:14 UTC
Data Size:             9.2 MB/1.00 GB (In compliance)
Tables:                6
Rows:                  -6/10000 (In compliance)
Fork/Follow:           Unsupported
Rollback:              Unsupported
Continuous Protection: Off
Add-on:                postgresql-rugged-59538
heroku pg:psql -c "\d" 
--> Connecting to postgresql-rugged-59538
                     List of relations
 Schema |         Name         |   Type   |     Owner      
--------+----------------------+----------+----------------
 public | ar_internal_metadata | table    | xzdtgqyfhtvpwu
 public | labels               | table    | xzdtgqyfhtvpwu
 public | labels_id_seq        | sequence | xzdtgqyfhtvpwu
 public | schema_migrations    | table    | xzdtgqyfhtvpwu
 public | taggings             | table    | xzdtgqyfhtvpwu
 public | taggings_id_seq      | sequence | xzdtgqyfhtvpwu
 public | tasks                | table    | xzdtgqyfhtvpwu
 public | tasks_id_seq         | sequence | xzdtgqyfhtvpwu
 public | users                | table    | xzdtgqyfhtvpwu
 public | users_id_seq         | sequence | xzdtgqyfhtvpwu

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
0
Help us understand the problem. What are the problem?