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 5 years have passed since last update.

メモ:Ruby on RailsアプリをHerokuへDeployするコマンド

Last updated at Posted at 2018-08-11

1 Gemfile修正

gem 'sqlite3', group: :development
gem 'pg', group: :production```

config/database.yml 加筆
```production:
  <<: *default
  adapter: postgresql
  encoding: unicode
  pool: 5```

``` bundle install```

2 アプリのフォルダに移動、herokuログイン
``` cd アプリ名前```
``` heroku login```

3 gitスタート
``` git init```

herokuダッシュボードでアプリ作成

4 リモートリポジトリを追加
``` git remote add heroku https://git.heroku.com/xxxxx-xxxxx-xxxxx.git```


5ファイルのコミット
``` git add *
 git commit -m "first deploy on heroku"
 git push heroku master```



6 db の migrate
``` heroku rake db:migrate```

7環境変数の設定
```heroku config:set ENV_NAME_1=value1 ENV_NAME_2=value2```

8 deployされたURLの確認
``` heroku open```

9 log確認
```heroku logs -t ```
直近250ログの確認
```heroku logs -n 250```

---
#余談:全てのレコードを空にする
pg@Heroku
```heroku restart && heroku pg:reset DATABASE --confirm アプリ名前 && heroku run rake db:migrate```

sqlite@ローカル
```rake db:reset```
- 全てのテーブルを drop
- "db/schema.rb" を元にテーブルを再作成

テーブル定義を変更した上で全てのレコードを空にする
```rake db:migrate:reset```
全てのテーブルを drop
"db/migrate/" 以下の全てのテーブルを再作成


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?