0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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

Posted at
この記事の環境
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
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?